Auxiliary Math Routines

Hugolib.h provides some “auxiliary math routines”, providing a range of useful functions.

Routine Returns:
abs(a) the absolute value of <a>
higher(a, b) the greater of <a> or <b>
lower(a, b) the lower of <a> or <b>
mod(a, b) the remainder of <a> divided by <b>
pow(a, b) <a> to the power of <b>

Examples:

Here is a routine that uses abs to determine if the difference between two numbers falls within a specified range:

routine IsNear(fir,sec,range)
{
    if (abs(fir - sec) <= range)
        return true
    else
        return false
}

In games with multiple windows, mod is nice for determining if you have an odd or even screen width (in characters):

        if mod(display.screenwidth,2)