Mixing operations with signed and unsigned types
Michal Minich
michal.minich at gmail.com
Tue Jun 29 16:55:20 PDT 2010
On Wed, 30 Jun 2010 00:30:19 +0100, Stewart Gordon wrote:
> Michal Minich wrote:
>> I was surprised by the behavior of division. The resulting type of
>> division in example below is uint and the value is incorrect. I would
>> expect that when one of operands is signed, then the result is signed
>> type.
>
> Going by the spec
> http://www.digitalmars.com/d/1.0/type.html "Usual Arithmetic
> Conversions"
> the compiler is behaving correctly.
point 4.4 in docs - "The signed type is converted to the unsigned type."
this is just not good for most common binary operators, it might be
useful for &, | and maybe shift, but they are quite less common....
More information about the Digitalmars-d-learn
mailing list