Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

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

Again, 128-bit integers double the number of fibonacci numbers we can generate, but this example only prints every 50th:

Large integers

Type int provides integers of an arbitrary size, but at the cost of reduced efficiency and higher memory demand:

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: