On Tuesday, 17 July 2018 at 21:18:12 UTC, John Colvin wrote:
On Tuesday, 17 July 2018 at 18:21:26 UTC, H. S. Teoh wrote:
But opCmp turns out to be a tarpit.  Here's why:


  According to the original claim, it should also return 0, for
  "incomparable".  However, this leads to problems:
Indeed. And it doesn't make sense at all.

Just do what std.typecons.Proxy does and return float.nan for the incomparable case.

Yes, that's the only way. Having this 4th value of opCmp is necessary for may types. In fact opCmp() it practically the only place where I
ever use the type "float", just to have the NaN.
If I really need floatingpoint arithmetic, I always use real (or at least double).

I would like to have a "signed boolean" type (with the values -1, 0, 1 and NaN) simply for all kind of sign operations. But ok, float is 32bit, and IEEE suggests a "half" type (16bit). As a "signed boolean" would need a byte anyway
there is no too much to gain.

Reply via email to