Not Adding 0.1 Correctly

This is super weird. I’ll give you a simple version of my script:

local count = 0
repeat
	count += 0.1
	print(count)
	task.wait(0.1)
until waiting == false

This should print out something like, 0.1, 0.2, 0.3 etc. but this is what’s printing out:

  09:48:27.167  0.1  -  Client - LocalScript:20
  09:48:27.268  0.2  -  Client - LocalScript:20
  09:48:27.369  0.30000000000000004  -  Client - LocalScript:20
  09:48:27.470  0.4  -  Client - LocalScript:20
  09:48:27.586  0.5  -  Client - LocalScript:20
  09:48:27.703  0.6  -  Client - LocalScript:20
  09:48:27.820  0.7  -  Client - LocalScript:20
  09:48:27.936  0.7999999999999999  -  Client - LocalScript:20
  09:48:28.053  0.8999999999999999  -  Client - LocalScript:20
  09:48:28.153  0.9999999999999999  -  Client - LocalScript:20
  09:48:28.268  1.0999999999999999  -  Client - LocalScript:20
  09:48:28.384  1.2  -  Client - LocalScript:20
  09:48:28.485  1.3  -  Client - LocalScript:20
  09:48:28.601  1.4000000000000001  -  Client - LocalScript:20
  09:48:28.718  1.5000000000000002  -  Client - LocalScript:20
  09:48:28.820  1.6000000000000003  -  Client - LocalScript:20
  09:48:28.935  1.7000000000000004  -  Client - LocalScript:20
  09:48:29.036  1.8000000000000005  -  Client - LocalScript:20
  09:48:29.155  1.9000000000000006  -  Client - LocalScript:20
  09:48:29.269  2.0000000000000004  -  Client - LocalScript:20
  09:48:29.386  2.1000000000000005  -  Client - LocalScript:20
  09:48:29.501  2.2000000000000006  -  Client - LocalScript:20
  09:48:29.602  2.3000000000000007  -  Client - LocalScript:20
  09:48:29.704  2.400000000000001  -  Client - LocalScript:20
  09:48:29.819  2.500000000000001  -  Client - LocalScript:20
  09:48:29.935  2.600000000000001  -  Client - LocalScript:20
  09:48:30.052  2.700000000000001  -  Client - LocalScript:20
  09:48:30.153  2.800000000000001  -  Client - LocalScript:20
  09:48:30.269  2.9000000000000012  -  Client - LocalScript:20
  09:48:30.377  3.0000000000000013  -  Client - LocalScript:20
  09:48:30.485  3.1000000000000014  -  Client - LocalScript:20
  09:48:30.587  3.2000000000000015  -  Client - LocalScript:20
  09:48:30.702  3.3000000000000016  -  Client - LocalScript:20
  09:48:30.819  3.4000000000000017  -  Client - LocalScript:20
  09:48:30.920  3.5000000000000018  -  Client - LocalScript:20
  09:48:31.035  3.600000000000002  -  Client - LocalScript:20
  09:48:31.135  3.700000000000002  -  Client - LocalScript:20
  09:48:31.251  3.800000000000002  -  Client - LocalScript:20
  09:48:31.368  3.900000000000002  -  Client - LocalScript:20
  09:48:31.469  4.000000000000002  -  Client - LocalScript:20
  09:48:31.570  4.100000000000001  -  Client - LocalScript:20
  09:48:31.684  4.200000000000001  -  Client - LocalScript:20
  09:48:31.785  4.300000000000001  -  Client - LocalScript:20
  09:48:31.885  4.4  -  Client - LocalScript:20
  09:48:32.001  4.5  -  Client - LocalScript:20
  09:48:32.102  4.6  -  Client - LocalScript:20
  09:48:32.219  4.699999999999999  -  Client - LocalScript:20
  09:48:32.335  4.799999999999999  -  Client - LocalScript:20
  09:48:32.435  4.899999999999999  -  Client - LocalScript:20
  09:48:32.537  4.999999999999998  -  Client - LocalScript:20
  09:48:32.652  5.099999999999998  -  Client - LocalScript:20
  09:48:32.752  5.1999999999999975  -  Client - LocalScript:20
  09:48:32.853  5.299999999999997  -  Client - LocalScript:20
  09:48:32.969  5.399999999999997  -  Client - LocalScript:20
  09:48:33.085  5.4999999999999964  -  Client - LocalScript:20
  09:48:33.203  5.599999999999996  -  Client - LocalScript:20
  09:48:33.321  5.699999999999996  -  Client - LocalScript:20
  09:48:33.434  5.799999999999995  -  Client - LocalScript:20
  09:48:33.535  5.899999999999995  -  Client - LocalScript:20
  09:48:33.651  5.999999999999995  -  Client - LocalScript:20
  09:48:33.752  6.099999999999994  -  Client - LocalScript:20
  09:48:33.868  6.199999999999994  -  Client - LocalScript:20
  09:48:33.969  6.299999999999994  -  Client - LocalScript:20
  09:48:34.085  6.399999999999993  -  Client - LocalScript:20
  09:48:34.202  6.499999999999993  -  Client - LocalScript:20
  09:48:34.319  6.5999999999999925  -  Client - LocalScript:20
  09:48:34.419  6.699999999999992  -  Client - LocalScript:20
  09:48:34.534  6.799999999999992  -  Client - LocalScript:20
  09:48:34.636  6.8999999999999915  -  Client - LocalScript:20
  09:48:34.751  6.999999999999991  -  Client - LocalScript:20
  09:48:34.852  7.099999999999991  -  Client - LocalScript:20
  09:48:34.968  7.19999999999999  -  Client - LocalScript:20
  09:48:35.085  7.29999999999999  -  Client - LocalScript:20
  09:48:35.202  7.39999999999999  -  Client - LocalScript:20
  09:48:35.302  7.499999999999989  -  Client - LocalScript:20
  09:48:35.403  7.599999999999989  -  Client - LocalScript:20
  09:48:35.518  7.699999999999989  -  Client - LocalScript:20
  09:48:35.636  7.799999999999988  -  Client - LocalScript:20
  09:48:35.752  7.899999999999988  -  Client - LocalScript:20
  09:48:35.855  7.999999999999988  -  Client - LocalScript:20
  09:48:35.967  8.099999999999987  -  Client - LocalScript:20
  09:48:36.085  8.199999999999987  -  Client - LocalScript:20
  09:48:36.202  8.299999999999986  -  Client - LocalScript:20
  09:48:36.302  8.399999999999986  -  Client - LocalScript:20
  09:48:36.418  8.499999999999986  -  Client - LocalScript:20
  09:48:36.829  8.599999999999985  -  Client
1 Like

Floating point numbers

Solution might be to use round to a decimal place.

Similar related problem below for reference:

2 Likes

I came into the same problem it’s the lua interpreter the problem