integer<nbits>
Arbitrary, fixed-size, integer with overflow and arithmetic exceptions
integer<nbits> is a 2's complement signed integer of arbitrary, but fixed size.
The type definition for arbitrary, but fixed-size integers in Universal is:
The integer type is parameterized in terms of the number of bits in a 2's complement encoding, and the block type to use in the representation. The type will automatically allocate the minimum number of blocks to represent the integer. Effectively, the size of the block type will define the memory alignment of integer values in arrays and vectors.
The integer type can be compiled with or without exceptions using a compile guard: INTEGER_THROW_ARITHMETIC_EXCEPTION, to be set before including the type in your module, like so:
By default, exceptions are not enabled. They are defined, but not thrown, so client code will work in either configuration.
The integer type can be used to replace native char/short/int/long/long long types with a type that can capture when a computation overflows.
And of course, the integer type can be used to accurately capture very large dynamic range integer arithmetic functions such as factorial and binomials by using large values of nbits. There is no limit to nbits, except time and space available on your machine.
Last updated