9999999999999999.0 - 9999999999999998.0

Samir samir at aol.com
Sun Jan 6 00:20:40 UTC 2019

I saw the following thread[1] today on Hacker News that discusses 
an article that compares how various languages compute 
9999999999999999.0 - 9999999999999998.0.  A surprisingly large 
number of languages return 2 as the answer.  I ran the following 
which returned 1:

import std.stdio: writeln;
void main(){

I don't know anything about IEEE 754[2] which, according to the 
HN discussion, is the standard for floating point arthimetic, but 
was pleasantly surprised to see how D handles this.  Does anyone 
know why?


[1] https://news.ycombinator.com/item?id=18832155
[2] https://en.wikipedia.org/wiki/IEEE_754

More information about the Digitalmars-d-learn mailing list