Copy link to clipboard
Copied
I attempted to add increment of .1 to a value using a for loop, but the for loop did not add to the value in precise increments.
So, instead of getting .1,.2,.3,.4, etc, I got the following when I traced the loop:
0
0.1
0.2
0.30000000000000004
0.4
0.5
0.6
0.7
0.7999999999999999
0.8999999999999999
0.9999999999999999
This throws my code off completely because it causes the loop to run one unnecessary time and the value returned causes other functions to work improperly. Please advise on how to fix this. I notice that this is not a problem once you get to .25.
use .toFixed(1); after the value
Copy link to clipboard
Copied
use .toFixed(1); after the value
Copy link to clipboard
Copied
Thanks for prompt response.
Copy link to clipboard
Copied
You're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now