Defines |
| #define | fpclassify(x) (sizeof(x)==sizeof(float)?_blm_fpclassf(x):_blm_fpclassd(x)) |
| | Classifies a real expression.
|
| #define | isnan(x) (sizeof(x)==sizeof(float)?_blm_isnanf(x):_blm_isnand(x)) |
| | Checks if a real expression is Not A Number.
|
| #define | isinf(x) (sizeof(x)==sizeof(float)?_blm_isinff(x):_blm_isinfd(x)) |
| | Checks if a real expression is infinite.
|
| #define | isfinite(x) (sizeof(x)==sizeof(float)?_blm_isfinf(x):_blm_isfind(x)) |
| | Checks if a real expression is a finite number.
|
| #define | iszero(x) (sizeof(x)==sizeof(float)?_blm_iszerof(x):_blm_iszerod(x)) |
| | Checks if a real expression is zero.
|
| #define | signbit(x) (sizeof(x)==sizeof(float)?_blm_isnegf(x):_blm_isnegd(x)) |
| | Checks if a real expression is negative.
|
| #define | isnormal(x) (fpclassify(x)==FP_NORMAL) |
| | Checks if a real expression is normalised.
|
Functions |
| double | ceil (double x) |
| | Rounds a number up to the nearest integer.
|
| float | ceilf (float x) |
| | Rounds a number up to the nearest integer.
|
| double | copysign (double a, double b) |
| | Changes a signum of a double to that of an other double.
|
| float | copysignf (float a, float b) |
| | Changes a signum of a double to that of an other double.
|
| double | fabs (double d) |
| | Absolute value of a double-precision float-point number.
|
| float | fabsf (float f) |
| | Absolute value of a single-precision float-point number.
|
| double | floor (double x) |
| | Rounds a number down to the nearest integer.
|
| float | floorf (float x) |
| | Rounds a number down to the nearest integer.
|
| double | frexp (double x, int *p) |
| | Splits a double number to a double mantissa and an integer exponent.
|
| float | frexpf (float x, int *p) |
| | Splits a float number to a float mantissa and an integer exponent.
|
| double | infinity (void) |
| | Returns positive infinity.
|
| float | infinityf (void) |
| | Returns positive infinity.
|
| double | ldexp (double x, int p) |
| | Multiplies a double with an integer power of 2.
|
| float | ldexpf (float x, int p) |
| | Multiplies a float with an integer power of 2.
|
| double | modf (double x, double *i) |
| | Extracts the signed integral and fractional parts of a number.
|
| float | modff (float x, float *i) |
| | Extracts the signed integral and fractional parts of a number.
|
| double | nan (const char *unused) |
| | Return a not-a-number.
|
| float | nanf (const char *unused) |
| | Return a not-a-number.
|
| double | round (double x) |
| | Round a number to the nearest integer.
|
| float | roundf (float x) |
| | Round a number to the nearest integer.
|
| double | trunc (double x) |
| | Truncate the number to the next integer towards zero.
|
| float | truncf (float x) |
| | Truncate the number to the next integer towards zero.
|
IEEE-754 format aware functions.
These functions and macros provide access to features that are IEEE-754 format specific and perform basic operations that need to know the actual internal representation of IEEE-754 numbers. They are pretty simple and fairly fast.
Rounds a number up to the nearest integer.
If the argument is infinite, NaN, zero or a value that represents an integer, then the value is returned as it is. For all other values the value representing the smallest integer that is not smaller than the argument is returned. That is, for negative numbers the fractional part is simply discarded, for positive numbers the fractional part is discarded and 1 is added to the number. E.g. 2.5 will change to 3.0 but -2.5 will be changed to -2.0.
- Parameters:
-
| x | The number to calculate the ceil of |
- Returns:
- The ceil of x, or x if x is already an integer, is infinite, is zero or is not a number.
Rounds a number up to the nearest integer.
If the argument is infinite, NaN, zero or a value that represents an integer, then the value is returned as it is. For all other values the value representing the smallest integer that is not smaller than the argument is returned. That is, for negative numbers the fractional part is simply discarded, for positive numbers the fractional part is discarded and 1 is added to the number. E.g. 2.5 will change to 3.0 but -2.5 will be changed to -2.0.
- Parameters:
-
| x | The number to calculate the ceil of |
- Returns:
- The ceil of x, or x if x is already an integer, is infinite, is zero or is not a number.
| double copysign |
( |
double |
a, |
|
|
double |
b | |
|
) |
| | |
Changes a signum of a double to that of an other double.
The returned value will have the same absolute value as the first argument and the same signum as the second argument. If the first argument is NaN, then the returned value will be NaN, if the second argument is NaN, then the behaviour is undefined.
- Parameters:
-
| a | The number of the absolute value is used |
| b | The number of which the signum is used |
- Returns:
- A value that has the absolute value of
a and the signum of b.
| float copysignf |
( |
float |
a, |
|
|
float |
b | |
|
) |
| | |
Changes a signum of a double to that of an other double.
The returned value will have the same absolute value as the first argument and the same signum as the second argument. If the first argument is NaN, then the returned value will be NaN, if the second argument is NaN, then the behaviour is undefined.
- Parameters:
-
| a | The number of the absolute value is used |
| b | The number of which the signum is used |
- Returns:
- A value that has the absolute value of
a and the signum of b.
| double floor |
( |
double |
x |
) |
|
Rounds a number down to the nearest integer.
If the argument is infinite, NaN, zero or a value that represents an integer, then the value is returned as it is. For all other values the value representing the largest integer that is not larger than the argument is returned. That is, for positive numbers the fractional part is simply discarded, for negative numbers the fractional part is discarded and 1 is subtracted from the number. E.g. 2.5 will change to 2.0 but -2.5 will be changed to -3.0.
- Parameters:
-
| x | The number to calculate the floor of |
- Returns:
- The floor of x, or x if x is already an integer, is infinite, is zero or is not a number.
Rounds a number down to the nearest integer.
If the argument is infinite, NaN, zero or a value that represents an integer, then the value is returned as it is. For all other values the value representing the largest integer that is not larger than the argument is returned. That is, for positive numbers the fractional part is simply discarded, for negative numbers the fractional part is discarded and 1 is subtracted from the number. E.g. 2.5 will change to 2.0 but -2.5 will be changed to -3.0.
- Parameters:
-
| x | The number to calculate the floor of |
- Returns:
- The floor of x, or x if x is already an integer, is infinite, is zero or is not a number.
| double modf |
( |
double |
x, |
|
|
double * |
i | |
|
) |
| | |
Extracts the signed integral and fractional parts of a number.
If the argument x is NaN or infinite, then NaN is returned and the location pointed by the i argument is untouched. Otherwise the integer part (as obtained by the trunc() function) of x is stored at the location pointed by i and x minus the stored value (that is, the fractional part of the number) is returned. The signum of the integral and fractional parts is the same as that of the x argument, as long as the value is nonzero. If either the stored or the returned value is 0, then the signum of that 0 is not guaranteed to match the signum of x.
- Parameters:
-
| x | The number to decompose to integer and fractional parts |
| i | Pointer to a location where the integer part will be stored. If the pointer is NULL, then the integer part will be discarded. |
- Returns:
- NaN if the
x argument was NaN or infinite, the signed fractional part of x otherwise.
| float modff |
( |
float |
x, |
|
|
float * |
i | |
|
) |
| | |
Extracts the signed integral and fractional parts of a number.
If the argument x is NaN or infinite, then NaN is returned and the location pointed by the i argument is untouched. Otherwise the integer part (as obtained by the trunc() function) of x is stored at the location pointed by i and x minus the stored value (that is, the fractional part of the number) is returned. The signum of the integral and fractional parts is the same as that of the x argument, as long as the value is nonzero. If either the stored or the returned value is 0, then the signum of that 0 is not guaranteed to match the signum of x.
- Parameters:
-
| x | The number to decompose to integer and fractional parts |
| i | Pointer to a location where the integer part will be stored. If the pointer is NULL, then the integer part will be discarded. |
- Returns:
- NaN if the
x argument was NaN or infinite, the signed fractional part of x otherwise.
| double nan |
( |
const char * |
unused |
) |
|
Return a not-a-number.
This function returns a non-signalling NaN. It has a parameter, which by the standard should be a string, describing what sort of a NaN it is. This library uses a fixed NaN pattern, namely setting every bit to 1. There is no formal specification for the meaning of the bits for a NaN, except one, which should be cleared for a signalling NaN and set for a quiet NaN. Since the library supports only quiet NaNs, this bit, together will all unspecified qualifier bits, is set.
- Parameters:
-
| unused | An unspecified qualifier for the NaN, not used by the function. |
- Returns:
- A non-signalling NaN
| float nanf |
( |
const char * |
unused |
) |
|
Return a not-a-number.
This function returns a non-signalling NaN. It has a parameter, which by the standard should be a string, describing what sort of a NaN it is. This library uses a fixed NaN pattern, namely setting every bit to 1. There is no formal specification for the meaning of the bits for a NaN, except one, which should be cleared for a signalling NaN and set for a quiet NaN. Since the library supports only quiet NaNs, this bit, together will all unspecified qualifier bits, is set.
- Parameters:
-
| unused | An unspecified qualifier for the NaN, not used by the function. |
- Returns:
- A non-signalling NaN
| double round |
( |
double |
x |
) |
|
Round a number to the nearest integer.
The function returns a double that represents the integer closest to its argument. If the fractional part of the argument is exactly 0.5, then the integer further away from 0 is returned.
The argument is returned unchanged if it was NaN or its absolute value was larger than 253; positive 0 is returned if the absolute value of the argument was less than 0.5 and the rounding result is returned otherwise.
- Parameters:
-
| x | The number to be rounded |
- Returns:
- The rounded value
Round a number to the nearest integer.
The function returns a float that represents the integer closest to its argument. If the fractional part of the argument is exactly 0.5, then the integer further away from 0 is returned.
The argumen is returned unchanged if it was NaN or its absolute value was larger than 224; positive 0 is returned if the absolute value of the argument was less than 0.5 and the rounding result is returned otherwise.
- Parameters:
-
| x | The number to be rounded |
- Returns:
- The rounded value