Why 0.1 + 0.2 == 0.3 in D?
assert(0.1 + 0.2 != 0.3); // shall be true is my favorite check that a language uses native floating point arithmetic. C++ #include <cstdio> int main() { printf("%d\n", (0.1 + 0.2 != 0.3)); return 0; } Output: 1 http://ideone.com/ErBMd Python print(0.1 + 0.2 != 0.3) Output: True http://ideone.com/TuKsd Other examples Java: http://ideone.com/EPO6X C#: http://ideone.com/s14tV Why is this not true for D? As understand D uses native floating point numbers. Is this a bug? Do they use some specific number representation? Something else? Pretty confusing. D import std.stdio; void main() { writeln(0.1