-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
Floating point (f32) within a struct renders incorrecly #665
Comments
Hello @JonoPrest That's how floating point numbers work. You hardly get a very precise one. Typically you can use a format string like "{:.2}" for that |
Hey @sunng87 I understand that's how they work but why is the rendering in hbs giving "0.800000011920929" while standard rust fmt implementation gives "0.8" on the same number? And why does it only do it when rendering from a struct and not just a standalone f32? Seems like a weird behaviour for rendering to me. |
Something is going wrong with floating point precision when rendering values inside a struct.
It works to render just the f32 value, and just to double check it also works to use rusts format implementation on the nested value.
But rendering nested struct value with hbs fails. The last assertion in this test fails with:
assertion
left == right
failedleft: "0.800000011920929"
right: "0.8"
The text was updated successfully, but these errors were encountered: