Skip to content

Fix handling of numeric values that can't be perfectly represented as floats#6

Open
ViaCelestia wants to merge 2 commits intodryruby:developfrom
ViaCelestia:numerics
Open

Fix handling of numeric values that can't be perfectly represented as floats#6
ViaCelestia wants to merge 2 commits intodryruby:developfrom
ViaCelestia:numerics

Conversation

@ViaCelestia
Copy link
Copy Markdown

Some values (like 66.6) can't be perfectly represented in floating-point, similar to how in decimal, 2/3 is represented as 0.333333333 ad infinitum. For these values, formatting them with %.15E can instead show how the value gets rounded by the floating-point representation, like "%.15E" % 66.6 yielding 6.659999999999999E+01 rather than the expected 6.66E+01. Without a forced precision, Ruby can recognize that it should just produce "66.6" so this version just uses #to_s and then does the rest of the calculations necessary to be able to mirror ECMA-262 that the RFC cites

File.exists? went away in ruby 3.2
This covers all of the test cases that were originally marked as
"Outside Ruby Range" and includes some additional tests from the
RFC8785 spec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant