Integer Types
Fuzion knows signed and unsigned integer types in different sizes: u8, u16, u32, u64, u128 for unsigned values, i8, i16, i32, i64, i128 for signed values. Furthermore, int and uint can represent signed and unsigned integers of arbitrary size.
32-bit integers
Here is a small example calculating fibonacci numbers using 32-bit integers:
Due to the range limitations of type u32, this produces an error for n > 45.
64-bit integers
The possible range of values can be doubled using 64-bit integers:
Here, this produces an error for n > 91.
128-bit integers
NYI: 128-bit integers are not supported yet.
large integers
NYI: Large integers are not supported yet.
integer as generic type
The abstract type integer
can be used to build a generic
function that works with integers of arbitrary sizes. The compiler will
specialize this code for the actual type that it is used with: