Skip to content

math

Various mathematical utilities. Johann only speaks integers, so it's pretty limited.

MAX_INTEGER

pub int MAX_INTEGER = 0x7fffffffffffffff;

The maximum representable integer: 2^63 - 1.

MIN_INTEGER

pub int MIN_INTEGER = 0x8000000000000000;

The minimum representable integer: -2^63.

abs

pub fn abs(int i)

I return the absolute value of the passed int.

imax

pub fn imax(int a, int b)

DEPRECATED: prefier max.

imin

pub fn imin(int a, int b)

DEPRECATED: prefer min.

max

pub fn max(int a, int b)

I return the larger of my two int arguments.

min

pub fn min(int a, int b)

I return the smaller of my two int arguments.

pow

pub fn pow(int a, int b)

I raise a to the power of b. I am exposed as a function instead of an operator to avoid associativity confusion. Negative exponents make no sense with integers, and so cause a panic.