Problem with object understanding and datatypes
Ali Çehreli
acehreli at yahoo.com
Fri May 24 13:49:42 PDT 2013
On 05/24/2013 01:19 PM, Namal wrote:
> if(rhs.max - rhs._value < _value)
I had a compilation error so I had to change that line to the following:
if(T.max - rhs._value < _value){
> assert(subyte(128) - subyte(129) == subyte(0));
> }
>
> But the last test does not pass.
255 - 129 is less than 128 so the result is T.max, which is 255, which
is not equal to 0.
> Why does the minus operation is treated in signed datatype, while + is
> unsigned?
I don't think that is happening at all but the rules can get pretty
confusing. See "Integer Promotions" and "Usual Arithmetic Conversions"
should be known in general: :)
http://dlang.org/type.html
Ali
More information about the Digitalmars-d-learn
mailing list