-
Notifications
You must be signed in to change notification settings - Fork 2
bad outputs for f2s #4
Comments
This is not a |
It's easiest if you just PR the tests; you can do that right from the web interface. |
I can add a PR with failing tests, sure; obviously would have to use
well in my mind this repo should eventually (looks like this could be soon given what you already have) replace system.addFloat, which is needed to properly close nim-lang/Nim#13196 (among other benefits) (and araq seems to agree with that direction see nim-lang/Nim#13364 (comment)) f2s(result: var string, x: float, fmt: string) = ...
# or maybe via static string if benchmarking shows it can affect performance in any way
f2s(result: var string, x: float, fmt: static string) = ...
doAssert f2s(1.2) == "1.2" # implies default fmt = "%g"
doAssert f2s(0.12, "%f") == "1.2e-1"
doAssert f2s(0.12, "%e") == "0.12"
doAssert f2s(0.12, "%g") == "0.12" # Use the shortest representation: %e or %f |
If they don't fail, then the tests aren't useful. There's a printf component to Ryu that we can port for printf-like behavior that is consistent with Ryu itself. This would be suitable for adoption in |
I know it's still WIP, but just for reference:
e0
should just be stripped.0
shouldn't be stripped before an exponentthat's for consistency with almost all languages; if needed i can do some more research to double check what's printed in other langs
The text was updated successfully, but these errors were encountered: