Skip to content

RFC: 64-bit integer type proposal improvements#182

Merged
vegorov-rbx merged 8 commits intomasterfrom
integer-improvements
Mar 25, 2026
Merged

RFC: 64-bit integer type proposal improvements#182
vegorov-rbx merged 8 commits intomasterfrom
integer-improvements

Conversation

@vegorov-rbx
Copy link
Copy Markdown
Collaborator

@vegorov-rbx vegorov-rbx commented Mar 18, 2026

This PR adds changes to the RFC following additional user feedback and early usage feedback.
It also fixes more wording issues and adds clarity to some changes that were not mentioned.

  • goes over how negative integer literals are supported
  • min/max are variadic to match the math library they mirror
  • band/bor/box/btest are variadic to match the bit32 library they mirror
  • gt/ge/ugt/uge comparisons to not worry about transforming the order to fit into the small set of operations
  • explicitly mention the change to tostring, type and typeof
  • mention support in rawequal; similar to previous base library functions, it is expected to work on any
  • remove integer.tostring since it duplicates tostring
  • add types.integer constant for use in type functions
  • math.mininteger and math.maxinteger moved to integer.minsigned and integer.maxsigned

Comment thread docs/type-long-integer.md Outdated
Comment thread docs/type-long-integer.md Outdated
Comment thread docs/type-long-integer.md Outdated
@AsynchronousAI
Copy link
Copy Markdown

Hi, I don’t know if this is the place to mention but a popcount function would also be helpful.

Not a requirement tho because it can still be manually implemented to be fast with countlz and countrz and a pop_lsb but having it be O(1) with CPU instructions would be extremely useful.

@vegorov-rbx
Copy link
Copy Markdown
Collaborator Author

Popcnt does make sense and it was considered.
The reason it was excluded is that it makes sense for bit32 library as well, so it could be a separate proposal to add to both.

@AsynchronousAI
Copy link
Copy Markdown

Popcnt does make sense and it was considered. The reason it was excluded is that it makes sense for bit32 library as well, so it could be a separate proposal to add to both.

One more thing, will a buffer.writei64 function be added?

Comment thread docs/type-long-integer.md

Integer value representing -2^63 (`-9_223_372_036_854_775_808i`)

### Extensions to the string library
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to support string.pack()/string.unpack()?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a section about it, it doesn't seem backwards compatible to accept integers in those functions.

Comment thread docs/type-long-integer.md
Comment thread docs/type-long-integer.md Outdated
Comment thread docs/type-long-integer.md
Comment thread docs/type-long-integer.md Outdated
Comment thread docs/type-long-integer.md
Comment thread docs/type-long-integer.md Outdated
Comment thread docs/type-long-integer.md
Comment on lines +42 to +45
Binary and hexadecimal literals can specify the full value including the sign bit:
```luau
local a = 0xFFFF_FFFF_FFFF_FFFFi -- -1i
local b = 0b11111111_11111111_11111111_11111111_11111111_11111111_11111111_11111111i -- -1i
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, what would -0xffffffffffffffffi be? Because depending on how that is parsed, it could either be 1 or -9223372036854775807.

Inversely, is -0x8000000000000000i invalid from overflow, or does it wrap back around to 0x8000000000000000i due to two's complement?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-0xffffffffffffffffi is 1i, -0x8000000000000000i is 0x8000000000000000i.

@vrn-sn
Copy link
Copy Markdown
Member

vrn-sn commented Mar 24, 2026

Wanted to mention that as part of this PR, maybe it's worth also amending this section of the math constants RFC (math-constants.md):

Integer types are not supported in Luau, so math.maxinteger and math.mininteger wouldn’t make much sense, but adding other commonly used constants would be an easy value-add for users of the language.

It's worth keeping up-to-date since Luau does now support integers, along with support for the integer library constants instead.

Maybe: "Luau supports similar integer constants through its integer library, but other commonly used math constants are an easy value-add for users of the language."

@vegorov-rbx
Copy link
Copy Markdown
Collaborator Author

Maybe: "Luau supports similar integer constants through its integer library, but other commonly used math constants are an easy value-add for users of the language."

Applied.

@vegorov-rbx vegorov-rbx merged commit d4e5ab3 into master Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants