Vtc.Utils.Rational (vtc v0.3.5) View Source
Helper functions and types for working with the Ratio module.
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
Specs
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
Specs
Does the divrem operation on a rational vale, returns a {whole_dividend, rational_remainder} tuple.
Specs
Rounds x
based on method
.
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.