Mathematical Functions

The ANSI library contains a variety of floating point functions. The standard interface, which is defined for type double, has been augmented by an alternate interface (and implementation) using type float.

Listing: ANSI-C Double-Precision mathematical functions


double acos(double x);
double asin(double x);

double atan(double x);

double atan2(double x, double y);

double ceil(double x);

double cos(double x);

double cosh(double x);

double exp(double x);

double fabs(double x);

double floor(double x);

double fmod(double x, double y);

double frexp(double x, int *exp);

double ldexp(double x, int exp);

double log(double x);

double log10(double x);

double modf(double x, double *ip);

double pow(double x, double y);

double sin(double x);

double sinh(double x);

double sqrt(double x);

double tan(double x);

double tanh(double x);

The functions using the float type have the same names with an f appended.

Listing: ANSI-C Single-Precision mathematical functions


float acosf(float x);
float asinf(float x);

float atanf(float x);

float atan2f(float x, float y);

float ceilf(float x);

float cosf(float x);

float coshf(float x);

float expf(float x);

float fabsf(float x);

float floorf(float x);

float fmodf(float x, float y);

float frexpf(float x, int *exp);

float ldexpf(float x, int exp);

float logf(float x);

float log10f(float x);

float modff(float x, float *ip);

float powf(float x, float y);

float sinf(float x);

float sinhf(float x);

float sqrtf(float x);

float tanf(float x);

float tanhf(float x);

In addition, the ANSI library also defines a couple of functions operating on integral values:

Listing: ANSI-C Integral functions


int    abs(int i);
div_t  div(int a, int b);

long   labs(long l);

ldiv_t ldiv(long a, long b);

Furthermore, the ANSI-C library contains a simple pseudo-random number generator and a function for generating a seed to start the random-number generator:

Listing: Random number generator functions


int  rand(void);
void srand(unsigned int seed);