# Math

The math library adds methods to the primitive data types of int, double, long, and complex.

``````  public int x;
formula a_x = Math.abs(x);
``````

``````  public int x;
formula a_x = x.abs();
``````

Also, many math functions also work on maybe types since some mathematical operators may be undefined (i.e. division by zero). Operating on maybe types, while inefficient, allows for expressive compute.

## Type: int

MethodDescriptionResult type
abs()Returns the absolute value of the given integer.int

## Type: long

MethodDescriptionResult type
abs()Returns the absolute value of the given long.long

## Type: double, maybe<double>

MethodDescriptionResult type
abs()Returns the absolute value of the given double.double
sqrt()Returns the square rootcomplex
ceil()-double
floor()-double
ceil(double precision)-double
floor(double precision)-double
round()-double
round(double precision)-double
roundTo(int digits)-double

Note; while many math functions are supported; they don't yet operate on maybe types; see #124

## Type: complex, maybe<compex>

MethodDescriptionResult type
conj()Returns the complex conjugate.complex
length()Returns the length of the complex number per the pythagorean theorem.double