Here's an even more glaring example:
In this case adding 1.0 works exactly, up to 2^24.
Thereafter adding 1.0 does nothing at all because that would require 25-bit precision.
Single precision floats are 24-bit.
; Puzzle about floating point: Why is size = 5000 so inaccurate? ; Short answer: Floats have 24-bit precision but 16777200 + 1 needs 25 bits. size = 500 ; Works exactly, but try 5000. sum# = 0 For i = 1 To size For j = 1 To size sum = sum + 1.0 Next Next Print " 'One at a time' sum = " + sum Print sum = 0 For i = 1 To size block# = 0.0 For j = 1 To size block = block + 1.0 Next sum = sum + block Next Print "'Block at a time' sum = " + sum WaitKey() : End
In this case adding 1.0 works exactly, up to 2^24.
Thereafter adding 1.0 does nothing at all because that would require 25-bit precision.
Single precision floats are 24-bit.