gZany So I'm trying to make a timer that subtracts only 0.1 every 100 milliseconds but it shows a trail of random 0's and 9's. How do I get it so that it only shows the first 2 numbers? My Code:
ackvonhuelio gZany might be a floating point error considering you're doing a repeated addition of -0.1 just put something like timer = round(timer*100)/100 to get rid of all decimals but the first two
MonsterYT_DaGamer I would like to see the full code along with it not being in blocks because it is very unreadable
Letti42 use Number.toFixed(<point>) to get it back to normal for example (0.60000000001).toFixed(1) returns "0.6" (as a string)
DragonFireGames Letti42 I first learned about that function while trying to make a digital stopwatch as well, it's been useful ever since.
DragonFireGames Also the reason you get the .9999999 or .0000004 is because floating point math cannot represent certain values as exact binary values. Kinda like how 1/3 is 0.3333333 in decimal. Try 0.1+0.2 in the console to see.