Problem with object understanding and datatypes

Namal sotis22 at mail.ru
Sat May 25 04:34:07 PDT 2013


On Saturday, 25 May 2013 at 10:15:42 UTC, bearophile wrote:
> Namal:
>
>> And if so, do I always have to use a suffix when the number is 
>> bigger than  uint?
>
> It looks a bit silly, I agree.
>
> Bye,
> bearophile

Well, now I have same Error for signed long:

else{
	static if (op == "+"){
		if(rhs._value > T.init && T.max - rhs._value < _value)
			return rhs.max;
		else if(rhs._value < T.init && T.min - rhs._value > _value)
			return rhs.min;
	}
	static if (op == "-"){
		if(rhs._value > T.init && T.min+rhs._value > _value)
			return rhs.min;
		else if(rhs._value < T.init && T.max + rhs._value < _value)
			return rhs.max;
	}
	static if (op == "/"){
		if(rhs._value == -1)
			return rhs.max;
	}

does work for every type exept long. Like for the addition


unittest{
	alias slong = Saturated!long;

	assert(slong(9_223_372_036_854_775_806) + slong(2) == 
slong(9_223_372_036_854_775_807));
	assert(slong(9_223_372_036_854_775_806) + slong(-3) == 
slong(-9_223_372_036_854_775_808));
}

The first test is ok, but second wont even compile. Even if I 
append a L to each number.


More information about the Digitalmars-d-learn mailing list