![]() |
[Pawn] Float bug ? - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10) --- Thread: [Pawn] Float bug ? (/showthread.php?tid=1057) |
Float bug ? - NexoR - 2020-04-19 Hello, I am working on height calculation. But some places seem incomplete and inaccurate. Can you help with this issue? My code: Code: for (new i = 1; i <= 35; i) Output: Code: 1.50 RE: Float bug ? - Markski - 2020-04-19 This is a floating point accuracy issue. It can be better seen when looking at the numbers on a larger scale. Code: 1.50999 A solution to this problem could be to just define i as a float from the let's go, and give it a value slightly higher than 1.0 to avoid floating point inaccuracy setting it below 1.0 Code: for (new Float:i = 1.0001; i <= 35.0; i) { This code prints as follows: Code: 1.51 |