ANN: SaferIntegers

Using the default Int or UInt types allows overflow and underflow errors to occur silently, without notice. And then to propagate as if the value obtained were correct. Such errors are difficult to recognize.

This package exports safer versions: SafeInt8, SafeInt16, SafeInt32, SafeInt64, SafeInt128 and similarly for UInts. The safer versions check for overflow/underflow in arithmetic functions. The processing will stop with a message in the event that either exception is encountered.

This is version 0.0.1, and comments are welcome. It is intended to be robust, performant, and play very well with the usual Int and UInt types. More information is available here.

11 Likes