Useful Math Routines
Header File | Example | Prototype | Explanation |
#include "stdlib.h" | max(a, b); | (type) max(a, b); | Returns whichever value is greater. |
#include "stdlib.h" | min(a, b); | (type) min(a, b); | Returns whichever value is less. |
#include "stdlib.h" | random(x); | int random(int num); | Returns a random number between 0 and x. |
#include "stdlib.h" #include "time.h" |
randomize(); | void randomize(void); | Randomizes the starting point for random numbers. |
#include "math.h" | M_PI | constant | The constant value for PI. |
#include "math.h" | sin(x); | double sin(double x); | Returns the sine of the angle (in radians) |
#include "math.h" | cos(x); | double cos(double x); | Returns the cosine of the angle (in radians) |
#include "math.h" | tan(x); | double tan(double x); | Returns the tangent of the angle (in radians) |
#include "math.h" | atan(x); | double atan(double x); | Returns the arc tangent of the value. |
#include "math.h" | asin(x); | double asin(double x); | Returns the arc sine of the value. |
#include "math.h" | acos(x); | double acos(double x); | Returns the arc cosine of the value. |
#include "math.h" | sqrt(x); | double sqrt(double x); | Returns the positive square root of x. |
#include "math.h" | pow(x, y); | double pow(double x, double y); | Returns x raised to the y power. |
#include "math.h" | abs(x); | int abs(int x); | Returns the absolute value of an integer. |