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

Number conversions #476

Closed
wants to merge 4 commits into from
Closed

Number conversions #476

wants to merge 4 commits into from

Conversation

mhermier
Copy link
Contributor

My attempt at fixing issue #454. I try to inline functions with one call site, and try rationalize string to Num conversion. By doing so there is only one utility function used to convert numbers to strings, that is now shared in Num::fromString and the compiler. Note that it accepts scientific and hexadecimal values.

In extra, but commented, there are 2 extra features:

  • Num::fromString would/should thow an error on invalid conversion, instead of returning null.
  • wrenNewNumFromStringLength can be hardened to detect precision loss in hex format.

@munificent
Copy link
Member

This looks pretty nice! A couple of questions:

  • Is there a reason you moved wrenNewStringFromDouble() into the header and made it inline? It seems a little large to benefit from that.

  • This means that Num.fromString() now accepts hex values too, right?

@mhermier
Copy link
Contributor Author

mhermier commented Nov 1, 2017 via email

@ruby0x1 ruby0x1 closed this Jun 12, 2020
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.

None yet

3 participants