std.conv.ConvOverflowException if the number exceeds the target type's range.
import std.conv : to, ConvOverflowException; import std.exception : assertThrown; assert(BigInt("0").to!int == 0); assert(BigInt("0").to!ubyte == 0); assert(BigInt("255").to!ubyte == 255); assertThrown!ConvOverflowException(BigInt("256").to!ubyte); assertThrown!ConvOverflowException(BigInt("-1").to!ubyte);
Implements casting to integer types.