On Saturday, 14 May 2016 at 01:26:18 UTC, Walter Bright wrote:
On 5/13/2016 5:49 PM, Timon Gehr wrote:
And even if higher precision helps, what good is a
"precision-boost" that e.g.
disappears on 64-bit builds and then creates inconsistent
results?
That's why I was thinking of putting in 128 bit floats for the
compiler internals.
I almost wonder if the cent/ucent will be avaliable soon as
types rather than reserved keywords.
Anyways my two cents. I remember having issues doing a direct
compare on an identical value when it was immutable which proved
false, and this made no sense and still doesn't. Regardless I've
tried to exhaustively do the compares and found some unexpected
results.
float f = 1.30;
const float cf = 1.30;
immutable If = 1.30;
writeln(f == 1.30); //false
writeln(cf == 1.30);
writeln(If == 1.30);
writeln(f == 1.30f);
writeln(cf == 1.30f);
writeln(If == 1.30f);
writeln(f == cf);
writeln(f == If); //false
writeln(If == cf);
The real reason it's false is because you're comparing against
an immutable (constant), or my results lead me to believe that;
Otherwise why could cf and If work?