Mathematical Functions

The ANSI library co ntains a variety of floating point functions. The standard interface, which is defined for type double ( Listing: ANSI-C Double-Precision Mathematical Functions), has been augmented by an alternate interface (and implementation) using type float ( Listing: ANSI-C Single-Precision Mathematical Functions).

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 float type functions use the same names with an appended f.

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 some functions operating on integral values (refer the following listing).

Listing: ANSI Functions with Integer Arguments
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 (refer the following listing) and a function using a seed to start the random-number generator.

Listing: Random-Number Generator Functions
int  rand(void);
void srand(unsigned int seed);