mikroSDK Reference Manual
ANSI C Math Library

ANSI C Math Library. More...

Functions list

double fabs (double num)
 Calculates floating point abolute value of given number. More...
 
double floor (double num)
 Rounds a number DOWN to the nearest integer. More...
 
double ceil (double num)
 Rounds a number UP to the nearest integer. More...
 
double frexp (double num, int16_t *exp_ptr)
 Function splits a floating-point number. More...
 
double ldexp (double num, int16_t new_exp)
 Calculates the result of multiplying the floating-point number by 2 raised to the power n. More...
 
double modf (double num, double *int_ptr)
 Splits argument num split to the fractional part (function return value) and integer part (in number int_ptr). More...
 
double sqrt (double num)
 Calculates square root of given number. More...
 
double atan (double num)
 Calculates arc tangent of given number. More...
 
double asin (double num)
 Calculates the arc sine of given number, in range [-1..+1]. More...
 
double acos (double num)
 Calculates the arccosine of given number, in range [-1..+1]. More...
 
double atan2 (double y, double x)
 Calculates the arctangent of given number, in range [-1..+1]. More...
 
double sin (double num)
 Calculates the sine of a given angle (in radians). More...
 
double cos (double num)
 Calculates the cosine of a given angle (in radians). More...
 
double tan (double num)
 Calculates the tangent of given angle (in radians). More...
 
double exp (double pow)
 Calculates the number e raised to the power of argument power. More...
 
double log (double num)
 Calculates the natural logarithm - ln( num ). More...
 
double log10 (double num)
 Calculates the base 10 logarithm. More...
 
double pow (double num, double pow)
 Calculates the power of a number. More...
 
double sinh (double num)
 Calculates the hyperbolic sine of a given number. If the value of num is too large (if overflow occurs), the function fails. More...
 
double cosh (double num)
 Calculates the hyperbolic cosine of given number. More...
 
double tanh (double num)
 Calculates the hyperbolic tangent of given number. More...
 

Detailed Description

ANSI C Math Library provides a set of standard ANSI C library functions for floating point math handling.

Function Documentation

◆ fabs()

double fabs ( double  num)

The fabs function computes the absolute value of a floating-point number num.

Calculates floating point abolute value of given number.

The fabs function computes the absolute value of a floating-point number num.

Parameters
[in]numNumber which the absolute value is calculated for.
Returns
The fabs function returns the absolute value of num.

◆ floor()

double floor ( double  num)

The floor function computes the largeht integral value not greater than num.

Rounds a number DOWN to the nearest integer.

The floor function computes the largeht integral value not greater than num.

Parameters
[in]numNumber to be rounded.
Returns
The floor function returns the largest integral value not greater than num. expressed as a double.

◆ ceil()

double ceil ( double  num)

The ceil function computes the smallest integral value not less than num.

Rounds a number UP to the nearest integer.

The ceil function computes the smallest integral value not less than num.

Parameters
[in]numNumber to be rounded.
Returns
The ceil function returns the smallest integral value not less than num, expressed as a double.

◆ frexp()

double frexp ( double  num,
int16_t *  exp_ptr 
)

The frexp function breaks a floating-point number into a normalized fraction and an integral power of 2. It stores the integer in the int object pointed to by exp_ptr.

Function splits a floating-point number.

The frexp function breaks a floating-point number into a normalized fraction and an integral power of 2. It stores the integer in the int object pointed to by exp_ptr.

Parameters
[in]numFloating point number that gets split.
[in]exp_ptrPointer to variable in which the exponent gets stored.
Returns
The frexp function returns the value x, such that x is a double with magnitude in the interval [1/2, 1) or zero, and value equals x times 2 raised to the power *exp. If value is zero, both parts of the result are zero.

◆ ldexp()

double ldexp ( double  num,
int16_t  new_exp 
)

The ldexp function multiplies a tloating-point number by an integral power of 2. A range error may occur.

Calculates the result of multiplying the floating-point number by 2 raised to the power n.

The ldexp function multiplies a tloating-point number by an integral power of 2. A range error may occur.

Parameters
[in]numFloating point number to be multiplied.
[in]new_expIntegral exponent.
Returns
The ldexp function returns the value of num times 2 raised to the power new_exp.

◆ modf()

double modf ( double  num,
double *  int_ptr 
)

The modf function breaks the argument value into integral and fractional parts, each of which has the same sign as the argument. It stores the integral part as a double in the object pointed to by int_ptr.

Splits argument num split to the fractional part (function return value) and integer part (in number int_ptr).

The modf function breaks the argument value into integral and fractional parts, each of which has the same sign as the argument. It stores the integral part as a double in the object pointed to by int_ptr.

Parameters
[in]numNumber that gets split.
[in]int_ptrPointer to variable in which the integer part gets stored.
Returns
The modf function returns the signed fractional part of num.

◆ sqrt()

double sqrt ( double  num)

The sqrt function computes the nonnegative square root of num. A domain error occurs if the argument is negative.

Calculates square root of given number

The sqrt function computes the nonnegative square root of num. A domain error occurs if the argument is negative.

Parameters
[in]numNumber the square root is calculated for.
Returns
The sqrt function returns the value of the square root.

◆ atan()

double atan ( double  num)

The atan function computes the principal value of the arc tangent of num.

Calculates arc tangent of given number.

The atan function computes the principal value of the arc tangent of num.

Parameters
[in]numNumber the arctangent is calculated for.
Returns
The atan function returns the arc tangent in the range [-?/2, +?/2] radians.

◆ asin()

double asin ( double  num)

The asin function computes the principal value of the arc sine of num. A domain error occurs for arguments not in the range [-1, +1].

Calculates the arc sine of given number, in range [-1..+1].

The asin function computes the principal value of the arc sine of num. A domain error occurs for arguments not in the range [-1, +1].

Parameters
[in]numNumber the arcsine is calculated for.
Returns
The asin function returns the arc sine in the range [-?/2. +?/2] radians.

◆ acos()

double acos ( double  num)

The acos tunction computes the principal value of the arc cosine of num. A domain error occurs for arguments not in the range [-1, +1].

Calculates the arccosine of given number, in range [-1..+1].

The acos tunction computes the principal value of the arc cosine of num. A domain error occurs for arguments not in the range [-1, +1].

Parameters
[in]numNumber which the arc cosine is calculated for.
Returns
The acos function returns the arc cosine in the range [0, ?] radians.

◆ atan2()

double atan2 ( double  y,
double  x 
)

The atan2 function computes the principal value of the arc tangent of y/x, using the signs of both arguments to determine the quadrant of the return value. A domain error may occur if both arguments are zero.

Calculates the arctangent of given number, in range [-1..+1].

The atan2 function computes the principal value of the arc tangent of y/x, using the signs of both arguments to determine the quadrant of the return value. A domain error may occur if both arguments are zero.

Parameters
[in]yFirst value.
[in]xSecond value.
Returns
The atan2 function returns the arc tangent of y/x in the range [-?, +?] radians.

◆ sin()

double sin ( double  num)

The sin function computes the sine of num (measured in radians).

Calculates the sine of a given angle (in radians).

The sin function computes the sine of num (measured in radians).

Parameters
[in]numNumber the sine is calculated for.
Returns
The sin function returns the sine value.

◆ cos()

double cos ( double  num)

The cos function computes the cosine of num (measured in radians).

Calculates the cosine of a given angle (in radians).

The cos function computes the cosine of num (measured in radians).

Parameters
[in]numNumber the cosine is calculated for.
Returns
The cos function returns the cosine value.

◆ tan()

double tan ( double  num)

The tan function returns the tangent of num (measured in radians).

Calculates the tangent of given angle (in radians).

The tan function returns the tangent of num (measured in radians).

Parameters
[in]numNumber the tangent is calculated for.
Returns
The tan function returns the tangent value.

◆ exp()

double exp ( double  pow)

The exp function computes the exponential function of pow. A range error occurs if the magnitude of pow is too large.

Calculates the number e raised to the power of argument power.

The exp function computes the exponential function of pow. A range error occurs if the magnitude of pow is too large.

Parameters
[in]powPower which the e constant is to be raised for.
Returns
The exp function returns the exponential value raised to the power of pow.

◆ log()

double log ( double  num)

The log function compute5 the natural logarithm of num. A domain error occurs if the argument is negative. A range error might occur if the argument is zero.

Calculates the natural logarithm - ln( num ).

The log function compute5 the natural logarithm of num. A domain error occurs if the argument is negative. A range error might occur if the argument is zero.

Parameters
[in]numNumber the natural logaritm is calculated from.
Returns
The log function returns the natural logarithm.

◆ log10()

double log10 ( double  num)

The log10 function computes the base-ten logarithm of x. A domain error occurs if the argument is negative. A range error may occur if the argument is zero.

Calculates the base 10 logarithm.

The log10 function computes the base-ten logarithm of x. A domain error occurs if the argument is negative. A range error may occur if the argument is zero.

Parameters
[in]numNumber the base 10 logaritm is calculated from.
Returns
The log10 function returns the base-ten logarithm.

◆ pow()

double pow ( double  num,
double  pow 
)

The pow function computes num raised to the power pow. A domain error occurs if num is negative and pow is not an integral value. A domain error occurs if the result cannot be represented when num is zero and pow is less than or equal to zero. A range error might occur.

Calculates the power of a number

The pow function computes num raised to the power pow. A domain error occurs if num is negative and pow is not an integral value. A domain error occurs if the result cannot be represented when num is zero and pow is less than or equal to zero. A range error might occur.

Parameters
[in]numNumber to be raised.
[in]powNumber which the num is raised to.
Returns
The pow tunction returns the value of num raised to the power pow.

◆ sinh()

double sinh ( double  num)

The sinh function computes the hyperbolic sine of num. A range error occurs if the magnitude of num is too large.

Calculates the hyperbolic sine of a given number. If the value of num is too large (if overflow occurs), the function fails.

The sinh function computes the hyperbolic sine of num. A range error occurs if the magnitude of num is too large.

Parameters
[in]numNumber the hyperbolic sine is calculated for.
Returns
The sinh function returns the hyperbolic sine value.

◆ cosh()

double cosh ( double  num)

The cash function computes the hyperbolic cosine of num. A range error occurs if the magnitude of num is too large.

Calculates the hyperbolic cosine of given number.

The cash function computes the hyperbolic cosine of num. A range error occurs if the magnitude of num is too large.

Parameters
[in]numNumber the hyperbolic cosine is calculated for.
Returns
The cash function returns the hyperbolic cosine value.

◆ tanh()

double tanh ( double  num)

The tanh function computes the hyperbolic tangent of num.

Calculates the hyperbolic tangent of given number.

The tanh function computes the hyperbolic tangent of num.

Parameters
[in]numNumber the hyperbolic tangent is calculated for.
Returns
The tanh function returns the hyperbolic tangent value.