Hello C3 community ! I need to have precise variables in my project but I noticed that if I add or substract a float to a variable, there will be a lot of numbers after the comma like in this example : Variable_issue.c3p
As long as I add/substract an integer, all is fine. But if I add/substract a float, it becomes a mess. How can I fix that ?
You can round to any number of decimals, for example:
Set var to round(var*10)/10 will give you 12.4
Use int() function
int(12.5659897) will return 12
Develop games in your browser. Powerful, performant & highly capable.
You can round to any number of decimals, for example: Set var to round(var*10)/10 will give you 12.4
OK, it could be a solution. But why this happens ?
en.wikipedia.org/wiki/Round-off_error
Normal part of computing
en.wikipedia.org/wiki/Round-off_error Normal part of computing
Wow !
Thank you ! :)