Fuzion Logo
flang.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:

signed integers
8 bits i8-128127
16 bits i16-3276832768
32 bits i32-2147483648-2147483647
64 bits i64-92233720368547758089223372036854775807
128 bits i128 (unsupported so far)-170141183460469231731687303715884105728170141183460469231731687303715884105727
dynamic size int (unsupported so far)
unsigned integers
8 bits u80255
16 bits u16065535
32 bits u3204294967295
64 bits u64018446744073709551615
128 bits u1280340282366920938463463374607431768211455
dynamic size uint (unsupported so far)0
8 bits
16 bits f16 (unsupported so far)9.2E413.4E38
32 bits f321.4E−453.4E38
64 bits f644.9E−3241.7976931348623157E308
128 bits f128 (unsupported so far)3.4E-49321.1897314953572317650857593266280070162E4932
dynamic size

Currently, 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.

Here is a small example that calculates and prints the ranges of unsigned 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 exmple 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 a intrinsic features such as fuzion.std.exit that never would return normally. See Type void for more information.