floating point errors

Get help using Construct 2

Post » Wed Aug 30, 2017 9:20 am

i have this function:
round(number*1000000000)/1000000000

i use it on all of my sprite font numbers, in order to avoid floating points error.
This work for 99% of the cases, and fixes most error caused by multiplying numbers
Yet, a number like this: 4418829.9
will be converted to: 4418829.900000001

i need to support up to 6 digits after dot

i dont understand how float number works and i need help

*simply removing a single 0 from 1000000000, seems to fix it for this specifc number
*i thought also trying to cut the last digit because i dont need that many
*but, if i try those fixes i will not know for sure the problem is fixed
B
41
S
16
G
7
Posts: 54
Reputation: 6,496

Post » Wed Aug 30, 2017 9:35 am

this might have happend because the bumber was too long
im going to split the number to 2 parts
right and left side of decimal point
im going to use the rounding only on the right part and the sum 2 parts
B
41
S
16
G
7
Posts: 54
Reputation: 6,496


Return to How do I....?

Who is online

Users browsing this forum: htmlgames, Matei511 and 63 guests