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

Fraction Types

Fuzion supports fraction types with all the standard numeric operations.

Fraction Example

Here is a small example declaring two fractions and performing basic arithmetic operations on them:







Fractions are based on any integer type, in this case on i32.

Overflow handling

Fractions suffer from the value limitations of their underlying integer types. See this example:







Using a larger integer type solves the overflow:







Using int as the base type avoids overflow altogether: