I’m trying to figure out how to add 0.1 to a number, I can add 0.0 + 0.1 = 0.1 and then 0.1+0.1= 0.2 but then when I get to 0.2+0.1 =.3000000000004 and then the next addition maybe correct and after that, the next set would be off and then everything is off from there.
Trouble with decimals
josephxbrick
#2
Hi!
That is annoying behavior! You can use the toFixed() function on the result to guarantee a certain number of decimal places. E.g., for one decimal place:
Set text on (label) to [[ (Target.text + 0.1).toFixed(1) ]]
powelds
#3
I have tried the .toFixed as well and still the same issue. I have tried a few different values,
- [[var1+0.1]]
- [[var1+0.1.toFixed(1)]]
- [[var1+1/10.toFixed(1)]]