int opEquals(Object), and other legacy ints

Walter Bright newshound at digitalmars.com
Sun Jul 30 01:16:40 PDT 2006


Deewiant wrote:
> Walter Bright wrote:
>> Stewart Gordon wrote:
>>> Walter Bright wrote:
>>>> I can. (a == b), where a and b are ints, can be implemented as (a -
>>>> b), and the result is int 0 for equality, int !=0 for inequality.
>>> How is this (a == b) rather than (a != b)?
>> I don't understand your question.
> 
> (a - b), if a and b are equal ints, evaluates to 0, which is generally
> considered to mean false. So isn't (a - b) actually a way of finding (a != b),
> instead of (a == b)?

Oh, I see what you mean.

To invert the result would take another 2 instructions for a total of 3, 
still less than 4.



More information about the Digitalmars-d-bugs mailing list