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

Ruby float literal format improvements: #107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

burke
Copy link

@burke burke commented Mar 12, 2024

  • Ruby floats are always formatted with an exponent sign.
  • Ruby floats break to scientific at e-4.
  • Ruby floats break to scientific at e14 (approximately).
  • Ruby uses "Infinity" and "NaN", but "Infinity".to_f and "NaN".to_f are 0

The true behaviour for the positive exponent break is more subtle than this. In addition to this, values between 1.0e15 and 1.0e16 can take either decimal or exponent form depending on the number of significant digits. I did not find a sane way to replicate this behaviour here.

* Ruby floats are always formatted with an exponent sign.
* Ruby floats break to scientific at e-4.
* Ruby floats break to scientific at e14 (approximately).
* Ruby uses "Infinity" and "NaN", but "Infinity".to_f and "NaN".to_f are 0

The true behaviour for the positive exponent break is more subtle than
this. In addition to this, values between 1.0e15 and 1.0e16 can take
either decimal or exponent form depending on the number of significant
digits. I did not find a sane way to replicate this behaviour here.
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

1 participant