evm v0.1.4 MathHelper

Simple functions to help with common math functions.

Link to this section Summary

Functions

Simple floor function that makes sure we return an integer type

Simple helper to calculate a log in any given base. E.g. the log_15(30), which would be expressed at MathHelper.log(30, 15)

Simple round function

Link to this section Functions

Link to this function floor(x)
floor(number) :: integer
floor(number) :: integer

Simple floor function that makes sure we return an integer type.

Examples

iex> MathHelper.floor(3.5)
3

iex> MathHelper.floor(-3.5)
-4

iex> MathHelper.floor(5)
5
Link to this function log(x, b)
log(number, number) :: number

Simple helper to calculate a log in any given base. E.g. the log_15(30), which would be expressed at MathHelper.log(30, 15).

Examples

iex> MathHelper.log(225, 15)
2.0

iex> MathHelper.log(240, 15)
2.0238320992392618

iex> MathHelper.log(1024, 10)
3.0102999566398116

iex> MathHelper.log(999999, 9999)
1.500016178459417

Simple round function

Examples

iex> MathHelper.round_int(3.5)
3
iex> MathHelper.round_int(-3.5)
-3
iex> MathHelper.round_int(-0.5)
0