How to detect overflow

BBasile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 3 20:22:01 PST 2015


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


More information about the Digitalmars-d-learn mailing list