On Sunday, 30 September 2012 at 17:07:19 UTC, monarch_dodra wrote:
As a rule of thumb, NEVER use opEqual with floating point types aniways. You need to use some sort of comparison with leway for error, such as std.math.approxEqual.

It is possible to compare exactly floating point types by binary comparison, if it provides some benefits.

import std.stdio;
import std.math;

@property float getFloat()
{
   return sqrt(1.1);
}

void main()
{
   writeln(getFloat is getFloat);  // doesn't fail
}

Reply via email to