On Monday, 9 May 2016 at 11:16:53 UTC, ZombineDev wrote:
On Monday, 9 May 2016 at 09:10:19 UTC, Walter Bright wrote:
Don Clugston pointed out in his DConf 2016 talk that:
float f = 1.30;
assert(f == 1.30);
will always be false since 1.30 is not representable as a
float. However,
float f = 1.30;
assert(f == cast(float)1.30);
will be true.
So, should the compiler emit a warning for the former case?
Yes, I think it is a good idea, just like emitting a warning
for mismatched signed/unsigned comparison.
I agree for the float but not for the long/ulong comparisons.
I often do code like "x < array.length" where x needs to be a
long to be able to handle negative values.
I want my code to compile without warning, and therefore I'm
against requiring "x < array.length.to!long()" to remove that
warning.