NumEx v0.1.0 Decimal_ View Source

A module to perform operations on decimal values

Link to this section Summary

Functions

Takes a Decimal value and returns its absolute value

Takes two Decimal values and compares them; returns “-1” if the first element is less than the second, “1” if it is greater and “0” if the elements are equal

Takes two Decimal values and compares them; returns “-1” if the first element is less than the second, “1” if it is greater and “0” if the elements are equal. However it helps comparing values like 1 and 1.0

Takes three decimal values and performs fast multiplication and addition i.e, for the arguments i, j, k the function returns the value i * j + k

Takes a Decimal value and returns if the value is signed

Link to this section Functions

Link to this function abs(n) View Source
abs(integer()) :: integer()

Takes a Decimal value and returns its absolute value

Examples

iex> Decimal_.abs(15)
15
iex> Decimal_.abs(-32)
32
Link to this function compare(n, m) View Source
compare(integer(), integer()) :: integer()

Takes two Decimal values and compares them; returns “-1” if the first element is less than the second, “1” if it is greater and “0” if the elements are equal

Examples

iex> Decimal_.compare(1, 5)
-1
iex> Decimal_.compare(1, -5)
1
iex> Decimal_.compare(4, 4)
0
Link to this function compare_total(n, m) View Source
compare_total(integer(), integer()) :: integer()

Takes two Decimal values and compares them; returns “-1” if the first element is less than the second, “1” if it is greater and “0” if the elements are equal. However it helps comparing values like 1 and 1.0

Examples

iex> Decimal_.compare_total(1, 5)
-1
iex> Decimal_.compare_total(1, -5)
1
iex> Decimal_.compare_total(4, 4)
0
iex> Decimal_.compare_total(1, 1.0)
-1
Link to this function fma(i, j, k) View Source
fma(integer(), integer(), integer()) :: integer()

Takes three decimal values and performs fast multiplication and addition i.e, for the arguments i, j, k the function returns the value i * j + k

Examples

iex> Decimal_.fma(2, 3, -5)
1
Link to this function is_signed(n) View Source
is_signed(integer()) :: boolean()

Takes a Decimal value and returns if the value is signed

Examples

iex> Decimal_.is_signed(10)
false
iex> Decimal_.is_signed(-10)
true
iex> Decimal_.is_signed(0)
false