-
Notifications
You must be signed in to change notification settings - Fork 2k
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
math.round returns 1 for 0.49999999999999994 #14755
Comments
I guess I can make the function shorter a little:
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as duplicate.
This comment was marked as duplicate.
This could even be written as a single line with It might be interesting to see how the performance compares (and whether there is anyone relying on rounding being particularly fast to begin with). |
Made a PR that fixes it. |
this..... is painful E |
Problem
As pointed out below the most popular answer on stackoverflow, Minetest's implementation of math.round suffers from a bug: https://stackoverflow.com/questions/18313171/lua-rounding-numbers-and-then-truncate
Solution
I rewrote math random this way:
Old:
New:
Steps to reproduce
Do this:
The text was updated successfully, but these errors were encountered: