Portability bug in integral conversion

so so at so.do
Mon Jan 17 02:50:49 PST 2011


> int difference(uint a, uint b) {
>    if (a >= b) {
>      return cast(int) a-b;
>    }
>    else {
>      return -(cast(int) b-a);
>    }
> }

Wouldn't this be just pushing a design error one step further?
uint has no mathematical basis whatsoever, it is there because we "can"  
have it.
I have another solution, remove "uint-uint" from the language and provide  
explicit functions.


More information about the Digitalmars-d mailing list