-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
How to format float64 to_s? #2220
Comments
Just use test = 9525365.25
puts "%.2f" % test Please consider using StackOverflow for such questions, thanks! |
Sorry for the misuse of the crystal github issues module. Thanks for your help. |
I find the default Float#to_s to be rather annoying and I would love if it returned nice numbers when it can. Ruby does a better job here. |
@ysbaddaden Me too. We just need to port this from C to Crystal ;-) |
Or we could just use it and have a wrapper for it. |
I found an alternative to Dragon4: Grisu3 by Florian Loitsch which is expected to be faster yet correct in 99.5% of cases. It's apparently used in V8 and by Mozilla, and a C library is available: https://github.com/google/double-conversion |
Hello:
In the next code
I would like to have a string with this format => "9525365.25"
The text was updated successfully, but these errors were encountered: