math.h

This header contains all math definitions and functions. Most are them analogous to what a standard C compiler includes


General definitions

Definitions: Numerical constants of interest
Name Value Description
pi 3.1415926 Value of pi with the precision allowed by a float
INT_MIN -2147483648 The minimum possible value of a 32-bit int
INT_MAX 2147483647 The maximum possible value of a 32-bit int

Arithmetic functions

Function: fmod
Prototype: float fmod( float x, float y )
Description: Calculates a float modulus: the remainder when Dividend/Divisor is truncated towards zero
Returns:
float Result
Arguments:
float x Dividend
float y Divisor

Comparison functions

Function: min
Prototype: int min( int a, int b )
Description: Returns the minimum of 2 integer values
Returns:
int Result
Arguments:
int a First value to compare
int b Second value to compare
Function: max
Prototype: int max( int a, int b )
Description: Returns the maximum of 2 integer values
Returns:
int Result
Arguments:
int a First value to compare
int b Second value to compare
Function: abs
Prototype: int abs( int a )
Description: Returns the absolute value of an integer
Returns:
int Result
Arguments:
int a The given value
Function: fmin
Prototype: float fmin( float x, float y )
Description: Returns the minimum of 2 float values
Returns:
float Result
Arguments:
float x First value to compare
float y Second value to compare
Function: fmax
Prototype: float fmax( float x, float y )
Description: Returns the maximum of 2 float values
Returns:
float Result
Arguments:
float x First value to compare
float y Second value to compare
Function: fabs
Prototype: float fabs( float x )
Description: Returns the absolute value of a float
Returns:
float Result
Arguments:
float x The given value

Float rounding functions

Function: floor
Prototype: float floor( float x )
Description: Round a float to the nearest integer, downwards
Returns:
float Result
Arguments:
float x Value to round
Function: ceil
Prototype: float ceil( float x )
Description: Round a float to the nearest integer, upwards
Returns:
float Result
Arguments:
float x Value to round
Function: round
Prototype: float round( float x )
Description: Round a float to the nearest integer
Returns:
float Result
Arguments:
float x Value to round

Trigonometric functions

Function: sin
Prototype: float sin( float angle )
Description: Calculates the sine of x
Returns:
float Result
Arguments:
float angle Angle, given in radians
Function: cos
Prototype: float cos( float angle )
Description: Calculates the cosine of x
Returns:
float Result
Arguments:
float angle Angle, given in radians
Function: tan
Prototype: float tan( float angle )
Description: Calculates the tangent of x
Returns:
float Result
Arguments:
float angle Angle, given in radians
Function: asin
Prototype: float asin( float x )
Description: Calculates the arc sine of x
Returns:
float Result, given in radians
Arguments:
float x The given value
Function: acos
Prototype: float acos( float x )
Description: Calculates the arc cosine of x
Returns:
float Result, given in radians
Arguments:
float x The given value
Function: atan2
Prototype: float atan2( float x, float y )
Description: Calculates the angle of a vector from the origin to a point with the given coordinates
Returns:
float Result, given in radians
Arguments:
float x X coordinate of the point
float y Y coordinate of the point

Exponential functions

Function: sqrt
Prototype: float sqrt( float x )
Description: Calculates the square root of x
Returns:
float Result
Arguments:
float x The given value
Function: pow
Prototype: float pow( float x, float y )
Description: Calculates x raised to the power of y
Returns:
float Result
Arguments:
float x The base
float y The exponent
Function: exp
Prototype: float exp( float x )
Description: Calculates the exponential of x (this is: e to the power of x)
Returns:
float Result
Arguments:
float x The given value
Function: log
Prototype: float log( float x )
Description: Calculates the natural logarithm of x (this is: with base e)
Returns:
float Result
Arguments:
float x The given value