How to detect overflow
    Namal via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Tue Nov  3 23:52:34 PST 2015
    
    
  
On Wednesday, 4 November 2015 at 04:22:03 UTC, BBasile wrote:
> On Wednesday, 4 November 2015 at 03:55:13 UTC, Namal wrote:
>> Is there a way to detect overflow for example for:
>>
>> 	int i = 2_000_000_000;
>> 	
>> 	int a = i*i*i;
>> 	
>> 	writeln(a);
>>
>> -> 1073741824
>
> You can use core.checkedint [1]
>
> ---
>
> http://dlang.org/phobos/core_checkedint.html
It says:
"The overflow is sticky, meaning a sequence of operations can be 
done and overflow need only be checked at the end."
But how can I make multiple operations? I can only put 2 values 
in the function.
    
    
More information about the Digitalmars-d-learn
mailing list