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

Basic Types

Numeric types

The following table gives an overview of the supported numeric types and their ranges:

kind
size
signed integers
type min max
8 bits i8 -128 127
16 bits i16 -32768 32768
32 bits i32 -2147483648 -2147483647
64 bits i64 -9223372036854775808 9223372036854775807
128 bits i128 (unsupported so far) -170141183460469231731687303715884105728 170141183460469231731687303715884105727
dynamic size int -∞ +∞
kind
size
unsigned integers
type min max
8 bits u8 0 255
16 bits u16 0 65535
32 bits u32 0 4294967295
64 bits u64 0 18446744073709551615
128 bits u128 0 340282366920938463463374607431768211455
dynamic size uint 0 +∞
kind
size
floats
type min max
8 bits
16 bits f16 (unsupported so far) 9.2E41 3.4E38
32 bits f32 1.4E−45 3.4E38
64 bits f64 4.9E−324 1.7976931348623157E308
128 bits f128 (unsupported so far) 3.4E-4932 1.1897314953572317650857593266280070162E4932
dynamic size

Types i128, f16 and f128 are not supported yet.

The default type of integer constants is currently i32, but this will most likely be changed to i64.

The default type of float constants is f64.

Here is a small example that calculates and prints the ranges of wrap-around integer types:

Boolean type

Boolean values true and false are of type bool, which is the required type for conditions used in if statements or in pre- and post-conditions among others.

Note that bool is fully implemented as a choice type of two unit types TRUE and FALSE.

Character types

There is no character type. It seems risky to define a type for the current 17 planes of Unicode code points. UTF-8 can address 32 planes in 4 bytes. Chances are high that someone will find a use for the additional planes or even extend UTF-8 to support more than 4 bytes per code point. Using i32 for a code point seems sufficiently safe for future Unicode changes.

The following gives a small example that extracts a slice of codepoints and a slice of bytes from a string to create a new string. Note that some emoji-symbols like ☯️ consist of several codepoints (U+262F U+FE0F, meaning yin-yang symbol U+262F in its graphical form U+FE0F), i.e., these might get modified when single codepoints are copied. Even worse, when single utf8-bytes are copied, non 7-bit ASCII characters may get crippled:

nil type

nil is defined as a unit type feature in the standard library. It is intended to be used to represent the absence of a value. Examples may be a lists tail that is empty or the result of a lookup that failed. See Type unit for more information.

void type

void is defined as an absurd feature in the standard library, i.e. a feature that cannot be instantiated since it requires a void type argument. It is intended to be used to represent the absence of a result. void is the result type of an endless loop or intrinsic features such as exit that never return. See Type void for more information.

last changed: 2024-06-28