I found this programming language challenge on HN: https://news.ycombinator.com/item?id=38952491
Nim v2.0.2 fails at this, giving 2.0 as the answer.
var c = 9999999999999999.0 - 9999999999999998.0
echo $c
I tried giving c type float64, but the answer is the same.
it works with decimal but not with floats
import decimal/decimal
let a = newDecimal("9999999999999999.0")
let b = newDecimal("9999999999999998.0")
echo a - b
What Every Computer Scientist Should Know About Floating-Point Arithmetic : https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
Just to emphasize what auxym just stated:
Your browser will fuck this up as well because JS does not have integers, its "number" type is all floats. Which is why your browser is incapable of handling really large numbers like that unless you start using BigInt.
If you want to test this out, open your browser console and enter 9999999999999999. You'll find said console not printing back out the number you typed in. Because the float spec is really screwy for representing large numbers with floats.
This works with MAPM as well. As everyone else have already pointed out it's just a quirk of how IEEE floating point numbers work. MAPM has some nice convenience features as well, so this works and produces the number 1:
import mapm
var c = 9999999999999999.0'm - 9999999999999998.0'm
echo c