std.experimental.safeint.d

Robert burner Schadek via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 7 13:27:03 PDT 2015


SafeInt!T is an integer wrapper struct with an explicit NaN value 
build on top of core.checkedint.

Features:

* checks if assigned values can be actually stored
* for SafeInt!u(T) NaN is T.max
* for SafeInt!T NaN is T.min
* SafeInt!T.opBinary("+","-","%","*","/") return SafeInt!T
   if value can not be store by SafeInt!T returned value is 
SafeInt!T.nan
* should be pretty much a act as any (u)integer type

Additionally, the module contains safe ==,!=,<,<=,>,>= 
comparisons functions

assert(-1 == uint.max); // this is wrongfully true
assert(notEqual(-1, uint.max)); // this asserts correctly true


More information about the Digitalmars-d mailing list