-
Hi everybody, I'm using a ESP32 DevKit C V2 I have some issues with the precision of floatingpoint calculations.
I would expect that, at least with the round() function, a correct result is achieved. Thanks in advance, Michael. |
Beta Was this translation helpful? Give feedback.
Answered by
robert-hh
Jan 19, 2024
Replies: 2 comments 6 replies
-
|
Beta Was this translation helpful? Give feedback.
5 replies
-
One of the things that has always puzzled me is that while the round function in upython can't seem to do the round up
whatever it is that does stringifying can
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I assume it's because of the fact, that there is no precise binary representation of 0.01. If you add that over and over, the error will sum up. Rounding after each step prevents this accumulation. If you write e.g.:
You will get a proper result. 1/128 can be exactly represented as binary number.