Lots of bool operations shouldn't compile

Don Clugston dac at nospam.com.au
Thu Mar 2 23:23:24 PST 2006


>>>> Yes, but that still doesn't work, there's no > for complex numbers.
>>>> Is  2 - 3i > 3 - 2i ?
>>>
>>> One could speak of their magnitudes, I suppose.
>>>
>>> creal i = 2 - 3i;
>>> creal j = 3 - 2i;
>>>
>>> real i_m = sqrt(i * complexConjugate(i));
>>> real j_m = sqrt(j * complexConjugate(j));
>>>
>>> but then I guess you are just comparing reals.
>>
>> And then you have the problem (as in this case) that
>> (i >= j) is true, and (i <= j) is true, but (i==j) is false.
>>
>> Actually, though, you _could_ bring the NCEG operators into play, and
>> define
>> a >  b  as   abs(a) > abs(b)
>> a >= b  as   abs(a) > abs(b) || a==b
>> a !< b  as   abs(a) !< abs(b)
>> a !<=b  as   abs(a) !< abs(b) && a!=b
>> a <> b  as   abs(a) != abs(b)
>> a !<>b  as   abs(a) == abs(b)
>> a == b  as   a == b
>> a <>=b  as   abs(a) <> abs(b) || a==b
>> a!<>=b  as   abs(a) == abs(b) && a!=b
>>
>> which would even work correctly with NANs.
>> But there's no mathematical precedent for this, AFAIK.
> 
> As long as its well documented and doesn't introduce bugs, why not?

I really don't think it's a good idea (mathematicians would laugh at 
us). If you want to compare the magnitudes, you should say so. But, I 
find it interesting that the NCEG operators allow you to define 
meaningful ordering comparisons for quantities for which a strict weak 
ordering does not exist.



More information about the Digitalmars-d-bugs mailing list