Vtc.Utils.Rational (vtc v0.3.2) View Source

Helper functions and types for working with the Ratio module.

Link to this section Summary

Types

t()

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 divmod operation on a rational vale, returns a {whole_dividend, rational_rainder} tuple.

Rounds a Ratio to the nearest integer.

Link to this section Types

Specs

t() :: Ratio.t() | integer()

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

divmod(t(), t()) :: {integer(), t()}

Does the divmod operation on a rational vale, returns a {whole_dividend, rational_rainder} tuple.

Specs

round(t()) :: integer()

Rounds a Ratio to the nearest integer.