Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support LuaJIT number notations (floating point, number suffixes) #255

Closed
rdw-software opened this issue Nov 24, 2022 · 5 comments
Closed
Labels
enhancement New feature or request

Comments

@rdw-software
Copy link

rdw-software commented Nov 24, 2022

See JohnnyMorganz/StyLua#621 :)


Example:

local num = 0x1p-1026
num = 0x1.5p-3

These are supported in LuaJIT and in fact used in its own Lua modules, e.g. here. Trying to format them results in a parser error:

image


More information about the extension:

tonumber() etc. use builtin string to number conversion

All string-to-number conversions consistently convert integer and floating-point inputs in decimal and hexadecimal on all platforms. strtod() is not used anymore, which avoids numerous problems with poor C library implementations. The builtin conversion function provides full precision according to the IEEE-754 standard, it works independently of the current locale and it supports hex floating-point numbers (e.g. 0x1.5p-3).

Source: https://luajit.org/extensions.html

@Kampfkarren
Copy link
Owner

Can you copy and paste the issue details here as well?

@rdw-software
Copy link
Author

Sure. Done!

@JohnnyMorganz
Copy link
Collaborator

Should probably also support LL and ULL number suffixes (looks like its case insensitive), and complex numbers 12.5i

@JohnnyMorganz JohnnyMorganz added the enhancement New feature or request label Dec 7, 2022
@JohnnyMorganz JohnnyMorganz changed the title Does not seem to support numbers in LuaJIT floating-point notation (?) Support LuaJIT number notations (floating point, number suffixes) Dec 7, 2022
@JohnnyMorganz
Copy link
Collaborator

Fixed in #258

@rdw-software
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants