RFC: 64-bit integer type proposal improvements#182
Conversation
|
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. |
|
Popcnt does make sense and it was considered. |
One more thing, will a |
|
|
||
| Integer value representing -2^63 (`-9_223_372_036_854_775_808i`) | ||
|
|
||
| ### Extensions to the string library |
There was a problem hiding this comment.
Do we want to support string.pack()/string.unpack()?
There was a problem hiding this comment.
Added a section about it, it doesn't seem backwards compatible to accept integers in those functions.
| 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
-0xffffffffffffffffi is 1i, -0x8000000000000000i is 0x8000000000000000i.
|
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):
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 |
Applied. |
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.
min/maxare variadic to match themathlibrary they mirrorband/bor/box/btestare variadic to match thebit32library they mirrorgt/ge/ugt/ugecomparisons to not worry about transforming the order to fit into the small set of operationstostring,typeandtypeofrawequal; similar to previous base library functions, it is expected to work onanyinteger.tostringsince it duplicatestostringtypes.integerconstant for use in type functionsmath.minintegerandmath.maxintegermoved tointeger.minsignedandinteger.maxsigned