So I was doing some work with some oddly specific numbers, and found this:
While the simple:
print(0.15 - 0.15)
equals '0', this:
print(0.15000000596046 - 0.15)
equals '5.9604600144425e-09' for some reason. It is messing up my script, and driving me crazy. Any ideas?
5.9604600144425e-09
equals 5.9604600144425*10^-9
. It's called scientific notation, and is used for dealing with really small/large numbers.
I can't think of any solution other than just not using 0.15000000596046.
You can remove that e-notation. Watch this:
local str = "0.15000000596046" local editedstr = string.format(".0f", str) local num = tonumber(editedstr) print(num - 0.15)