View Source Vtc.Utils.Rational (vtc v0.4.0)
Utilities for working with Ratio
vales.
Link to this section Summary
Types
The Ratio module will often convert itself to an integer value if the result would be a whole number, but otherwise return a %Ratio{} struct.
Functions
Does the divrem operation on a rational vale, returns a {whole_dividend, rational_remainder} tuple.
Rounds x
based on method
.
Link to this section Types
The Ratio module will often convert itself to an integer value if the result would be a whole number, but otherwise return a %Ratio{} struct.
This type can be used when working with such a value.
Link to this section Functions
Does the divrem operation on a rational vale, returns a {whole_dividend, rational_remainder} tuple.
Rounds x
based on method
.
arguments
Arguments
x
: The Rational value to round.method
: Rounding strategy. Defaults to:closest
.:closest
: Round the to the closet whole frame, rounding up when fractional remainder is equal to1/2
.:floor
: Always round down to the closest whole-frame.:ciel
: Always round up to the closest whole-frame.:off
: Pass value through without rounding.