rxi / fe

A tiny, embeddable language implemented in ANSI C
MIT License
1.31k stars 82 forks source link

Is this a floating point problem? #30

Open stacksmith opened 1 year ago

stacksmith commented 1 year ago

A simple loop locks up:

(= i 0)
(while (< i 19000000)
   (= i (+ i 1)))

Is there a preferred way to count?

ooichu commented 1 year ago

Yes, this is a problem related to floating point numbers. After number 16777216 for 4-byte float the accuracy drops, and incrementation has no effect.