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

fraction

🌌fraction

fraction


fraction provides fraction numbers based on an integer type to represent the
numerator and the denominator.

basic numeric operations +, -, * and comparison are supported. numerator and
denominator are reduced after each operation.

there are currently no checks or preconditions for overflows in the numerator
or the denominator.

just for brevity


redefines Object.asString:


redefines numeric.infix !=:


redefines numeric.infix *:
basic operations: 'infix *' (multiplication)


redefines numeric.infix +:
basic operations: 'infix +' (addition)


redefines numeric.infix -:
basic operations: 'infix -' (substraction)


redefines numeric.infix /:
basic operations: 'infix /' (division)


redefines ordered.infix <:
does this come strictly before other?


redefines partiallyOrdered.infix <=:
does this come before other?

comparison
redefines numeric.infix ==:
comparison


redefines ordered.infix >:
does this come strictly after other?


redefines ordered.infix >=:
does this come after other?


redefines numerics.one:
identity element for 'infix *'

basic operations
redefines numeric.prefix +:
basic operations: 'prefix +' (identity)


redefines numeric.prefix -:
basic operations: 'prefix -' (negation)

reduce numerator and denominator by their gcd:

enable generic features in ancestors
redefines numeric.thiz:
get numeric.this value of type T. This is used for a generic implemention
of some features (e.g. prefix -, abs


redefines numerics.zero:
identity element for 'infix +'