fp64lib Library reference (A-Z)

Reference by Functional Groups here…

abs

float64_t fp64_abs( float64_t x);

Return absolute value of x, removing sign. This works even if x is NaN, Inf or zero.

acos

float64_t fp64_acos( float64_t x );

Returns the arcus cosine of x, the inverse function to fp64_cos(). The following special cases apply:

casexfp64_acos(x)
1NaNNaN
2x > +1 (incl. +INF)NaN
3x < -1 (incl. -INF)NaN

acosh

float64_t fp64_acosh( float64_t x );

returns the inverse hyperbolic cosine (a.k.a. area hyperbolic cosine) of x, which  is defined mathematically as

arcosh(x) = ln(x + sqrt(x*x-1)) for x >= 1

If x < 1, NaN is returned.

Available with release 1.1.20 onwards.

add (+)

float64_t fp64_add( float64_t A, float64_t B );

Adds two 64 bit floating point numbers and rounds result to a 64bit floating point number. The following special cases apply:

caseABfp64_add(A,B)
1NaN any NaN
2anyNaNNaN
3a+Inf-InfNaN
3b+Inf+Inf+Inf
3c-Inf-Inf-Inf
3d-Inf+InfNaN
4InfanyInf
5anyInfInf
60anyany
7any0any

asin

float64_t fp64_asin(float64_4 x );

Returns the arcus sine of x, the inverse function to fp64_sin(). The following special cases apply:

casexfp64_asin(x)
1NaNNaN
2x > +1 (incl. +INF)NaN
3x < -1 (incl. -INF)NaN

asinh

float64_t fp64_asinh( float64_t x );

returns the inverse hyperbolic sine (a.k.a. area hyperbolic sine) of x, which is defined mathematically as

arsinh(x) = ln(x + sqrt(x*x+1))

Available with release 1.1.20 onwards.

The following special cases apply:

casexfp64_asinh(x)
1NaNNaN
2a+Inf+Inf
2b-Inf-Inf

atan

float64_t fp64_atan( float64_t x );

Returns the arcus tangent of x, the inverse function to fp64_tan(). The following special cases apply:

casexfp64_atan(x)
1NaNNaN
2a+Inf+PI/2
2b-Inf-PI/2

atan2

float64_t fp64_atan2 ( float64_t A, float64_t B );

The fp64_atan2() function calculates the arc tangent of the two variables A and B, where A can be interpreted as the y coordinate and B as the x coordinate. It is similar to calculating the arc tangent of A/B, except that the signs of both arguments are used to determine the quadrant of the result. The fp64_atan2() function returns the result in radians, which is between -PI and PI (inclusive):

Sector|   x  |   y  | |y|<=|x| | result range
------+------+------+----------+-----------------
I | >= 0 | >= 0 | yes | 0..PI/4
II | >= 0 | >= 0 | no | PI/4..PI/2
III | < 0 | >= 0 | no | PI/2..3*PI/4
IV | < 0 | >= 0 | yes | 3*PI/4..PI
V | < 0 | < 0 | yes | -PI..-3*PI/4
VI | < 0 | < 0 | no | -3*PI/4..-PI/2
VII | >= 0 | < 0 | no | -PI/2..-PI/4
VIII | >= 0 | < 0 | yes | -PI/4..0

Note:
Unlike the 32bit floating library, this implementation respects all four
cases of 0/0, like x86 (GCC/Glibc): +0/+0, +0/-0, -0/+0 and -0/-0.

Note: Unlike the 32bit floating library, this implementation respects all four cases of 0/0, like x86 (GCC/Glibc): +0/+0, +0/-0, -0/+0 and -0/-0.

The following special cases apply:

caseA = yB = xfp64_atan2(A,B)
1aNaN any NaN
1banyNaNNaN
2a+0>= 0+0
2b+0< 0+PI
2c-o>= 0-0
2d-0< 0-PI
3a+finite+Inf+0
3b+finite-Inf+PI
3c-finite+Inf-0
3d-finite-Inf-PI
3e+/- Inf+/- InfNaN
3f+/- Infany+/- PI/2
4|y| <= |x|>= 0see sector I & VIII: atan(y/x)+0
5 |y| <= |x| < 0see sector IV & V: atan(y/x)+/-PI
6 >= 0 |y| > |x|see sector II & III: -atan(x/y)+PI/2
7< 0 |y| > |x| see sector VI & VII: -atan(x/y)-PI/2
8a+any+/- 0+PI/2
8a-any+/-0-PI/2

atanh

float64_t fp64_atanh( float64_t x );

returns the inverse hyperbolic tangent (a.k.a. area hyperbolic tangent) of x, which is defined mathematically as

artanh(x) = 0.5*ln((1+x)/(1-x)) for |x| < 1

If x is >= 1, NaN is returned.

Available with release 1.1.20 onwards.

atof

float64_t fp64_atof( char *str );

converts a string to a number, handles also NaN, +INF, -INF.
A valid number (non NaN or INF) can be expressed by the
following regex: [+-]?[0-9]+\.?[0-9]*([eE][+-]?[0-9]+)?

cbrt

float64_t fp64_cbrt(float64_t x);

The fp64_cbrt() returns the cubic root of x. Works for positive and
negative values of x.

ceil

float64_t fp64_ceil( float64_t A );

Rounds A upwards to the nearest integer greater or equal A.
For A < 0 this is identical to trunc(A). The following rules apply:

caseAfp64_ceil(A)
0x < 0fp64_trunc(A)
1NaNNaN
2+Inf+Inf
3+0+0
4A >= 2^52A
50 < A < 11.0
61 <= A < 2^52fp64_ceil(A)

classify

int fp64_classify( float64_t x );

Categorizes floating point value x into the following categories:
zero, subnormal, normal, infinite, and NAN.
The following cases apply:

caseAfp64_classify(x)
1NaN1 (FP_NAN)
2+/- Inf2 (FP_INFINITE)
3+/- 00 (FP_ZERO)
4< 2^-10233 (FP_SUBNORMAL)
5any4 (FP_NORMAL)

compare ( <, ==, > )

float64_t fp64_compare (float64_t A, float64_t B);

Compares the two values A and B and returns -1/0/1, based on the following rules:

caseABfp64_compare(A,B)
1NaNany+1
2anyNaN+1
3A < Bany-1
4A == Bany0
5A > Bany1

copysign

float64_t fp64_copysign ( float64_t x, float64_t y );

The fp64_copysign() function returns x but with the sign of y. This works even if x or y are NaN, Inf or zero.

cos

float64_t fp64_cos( float64_t phi );

Returns the cosine of phi. The following special cases apply:

casexfp64_cos(x)
1NaNNaN
2+INFNaN
3-INFNaN

cosh

float64_t fp64_cosh( float64_t x );

The fp64_cosh() function returns the hyperbolic cosine of x, which is
defined mathematically as (exp(x) + exp(-x)) / 2.

cotan

float64_t fp64_cotan( float64_t x );

The fp64_cotan() function returns the cotangent of x, which is
defined mathematically as cos(x) / sin(x) or 1/tan(x).

fp64_cut_noninteger_fraction

float64_t fp64_cut_noninteger_fraction( float64_t x );

Alias to fp64_trunc, see there.

div ( / )

float64_t fp64_div( float64_t A, float64_t B );

Divides two 64 bit floating point numbers and rounds result of A/B to a 64bit floating point number. The following special cases apply:

caseABfp64_div(A,B)
1NaN any NaN
2anyNaNNaN
3Inf0NaN
4InfInfNaN
50Inf0
6Inf!= 0Inf
7!= 0Inf0
800NaN
90!= 00

(float)

float fp64_ds( float64_t A );

Converts a float64 to the float32 representing the same number. Significand is rounded up, if bit 25 of significand of A is set.
As the range of float is significandly smaller than float64_t,
the following rules apply:

caseAfp64_ds(x) as hexfp64_ds(x)
1NaN 0x7fffffffNaN in float
2+Inf 0x7f800000 +Inf in float
3-Inf 0xff800000 -Inf in float
40.0 0x00000000 0.0
5-0.0 0x80000000 -0.0
6x >= 2^128 0x7f800000 +Inf in float
7-2^128 <= x 0xff800000 -Inf in float
80 < x < 2^-149 0x00000000 0.0 as float, underflow
9-2^-149 < x < 0 0x80000000 -0.0 as float, underflow
102^-149 < x < 2^-126 0x00mmmmmm subnormal number with mmmmmm < 0x800000
11-2^-126 < x <-2^-149 0x80mmmmmm subnormal number with mmmmmm < 0x800000
122^-126 <|x|< 2^127(float) A

exp

float64_t fp64_exp (float64_t x);

The fp64_exp() function returns the value of e (the base of natural
logarithms) raised to the power of x (e^x). The following rules apply:

casexfp64_exp(x)
1NaNNaN
2+Inf+Inf
3-Inf0
401
5> 709+Inf (Overflow)
6< -7440 (Underflow)
7!= 0A
80NaN
900

exp10

float64_t fp64_exp10 (float64_t x);

The fp64_exp10() function returns the value of 10 raised to the power of x, i.e. 10^x.

fdim

float_64t fp64_fdim (float_64t A, float_64t B);

The fp64_fdim() function returns max(A-B,0). If x or y or both are NaN, NaN is returned.

(long)

long fp64_float64_to_long( float64_t A );

Alias to fp64_to_int32, see there.

floor

float64_t fp64_floor( float64_t A );

Rounds A downwards to the nearest integer less or equal A. For A > 0 this is identical to trunc(A).

Examples:
fp64_floor(1.9) --> 1.0
fp64_floor(-1.9) --> -2.0

The following rules apply:

caseAfp64_floor(A)
0x > 0fp64_trunc(A)
1NaNNaN
2InfInf
3+0+0
4A <= -2^52A
5-1 <= A < 0-1.0
6-2^52 <= A < -1fp64_floor(A)

fma

float64_t fp64_fma (float64_t A, float64_t B, float64_t C);

The `fp64_fma’ function performs floating-point multiply-add. This is the operation (A * B) + C. Current implementation is space optimized, so no effort is taken to work on internal intermediate result. Only advantage for the caller is to save space for the call sequence.

fmax

float64_t fp64_fmax (float64_t A, float64_t B);

The fp64_fmax() function returns the greater of the two values A and B.
The following rules apply:

caseABfp64_fmax(A,B)
1NaNanyNaN
2anyNaNNaN
3< 0>= 0B
4>= 0< 0A
5A >= BanyA
6A < BanyB

fmin

float64_t fp64_fmin(float64_t A, float64_t B);

The fp64_fmin() function returns the lesser of the two values A and B.
The following rules apply:

caseABfp64_fmax(A,B)
1NaNanyNaN
2anyNaNNaN
3< 0>= 0A
4>= 0< 0B
5A >= BanyB
6A < BanyA

fmod ( % )

float64_t fp64_fmod (float64_t x, float64_t y);

The fp64_fmod() function computes the remainder of dividing x by y. The
return value is x – n*y, where n is the quotient of x/y, rounded
towards zero to an integer. The following rules apply:

caseABfp64_fmod(A,B)
1NaNanyNaN
2anyNaNNaN
3Inf0NaN
4InfInfNaN
5Inf!= 0NaN
60Inf0
7!= 0InfA
800NaN
90!= 00

fmodn

float64_t fp64_fmodn( float64_t x, float64_t y, unsigned long *np );

Like fp64_fmod, fp64_fmodn() function computes the remainder of dividing x by y. The return value is x – n*y, where n is the quotient of x/y, rounded towards zero to an integer. If pointer a pointer np != NULL is passed, the value of n will be stored in *np. See fp64_fmod for further rules.

Available with release 1.08 onwards.

fp64_fmodx_pi2

float64_t fp64_fmodx_pi2( float64_t x, unsigned long *np );

Computes the remainder of dividing x by Π/2 with extended 96-bit internal precision to avoid loss of significand digits for x >> Π. The return value is Π/2 – n*y, where n is the quotient of x/(Π/2), rounded towards zero to an integer. If pointer a pointer np != NULL is passed, the value of n will be stored in *np. See fp64_fmod for further rules.

Available with release 1.08 onwards.

frexp

float64_t fp64_frexp (float64_t A, int *pexp);

The fp64_frexp() function is used to split the number A into a normalized
fraction and an exponent which is stored by pexp.

Return:
If A is a normal float point number, the fp64_frexp() function returns the
value v, such that v has a magnitude in the interval [1/2, 1) or zero,
and A equals v times 2 raised to the power *pexp. If A is zero, both
parts of the result are zero. If A is not a finite number, the fp64_frexp()
returns A as is and stores 0 by pexp.

Note:
This implementation permits a zero pointer as a directive to skip
a storing the exponent.

hypot

float64_t fp64_hypot(float64_t x, float64_t y);

The float64_t() function returns `sqrt (x*x + y*y)’. This is the length
of the hypotenuse of a right triangle with sides of length x and y,
or the distance of the point (x, y) from the origin.

ilogb

int fp64_ilogb(float64_t x)

Returns the integral part of the logarithm of |x| to base 2. This is the exponent used internally to express the floating-point value x, when it uses a significand between 1.0 and 2, so that, for a positive x

x = significand * 2^exponent

Generally, the value returned by this function is one less than the exponent obtained with frexp (because of the different significand normalization as [1.0,2.0) instead of [0.5,1.0)).

Available with release 1.1.20 onwards.

The following rules apply:

casexfp64_ilogb(x)
1NaNFP_ILOGBNAN
2+/-INFINT_MAX
3+/-0.0FP_LOGB0
4elsesignificand * 2^exponent

(double) long int

float64_t fp64_int32_to_float64 ( long x );

Convert a signed 32-bit integer (long) to float64_t.
No overflow will occur, as 32bit long will always fit into the 53-bit significand.

(double) long long int

float64_t int64_to_float64( long long x );

Convert a signed 64-bit integer (long long) to float64_t.
Overflow cannot occur, but loss of precision, if abs(x) > 2^53

inverse

float64_t inverse (float64_t A);

The inverse() function returns 1/A value.

isfinite

int fp64_isfinite (float64_t x);

The isfinite() function returns a nonzero value if x is finite: not
plus or minus infinity, and not NaN.

isinf

int fp64_isinf (float64_t);

The fp64_isinf () function returns -1 if value represents negative
infinity, 1 if value represents positive infinity, and 0 otherwise.

isnan

int fp64_isnan( float64_t x );

The fp64_isnan() function returns a non-zero value if value is
“not-a-number” (NaN), and 0 otherwise.

ldexp

float64_t fp64_ldexp (float64_t x, int exp);

The fp64_ldexp() function returns the result of multiplying the
floating-point number x by 2 raised to the power exp.
The following rules apply:

casexfp64_ldexp(x,exp)
1NaNNaN
2+/- Inf+/- Inf
3+/- 0+/- o
4exponent(x)+exp>1023+/- Inf (Overflow)
5exponent(x)+exp<-1074+/- 0.0 (Underflow)
6exponent(x)+exp<-1023x*2^exp as subnormal number
7exponent(x)+exp<-1023 x*2^exp

log

float64_t fp64_log( float64_t x );

returns the natural logarithm ln of x. The following rules apply:

casexfp64_log(x)
1< 0NaN (< 0 includes -Inf)
2NaNNaN
3+Inf+/- o
40-Inf
510

logb

float64_t fp64_logb( float64_t x );

returns the base 2 logarithm of |x|.  logb(A) = log2(|x|) = log(|x|) / log(2)

Available with release 1.1.20 onwards.

log10

float64_t fp64_log10( float64_t A );

The fp64_log10() function returns the base 10 logarithm of A.
log10(A) = log(A) / log(10).

log2

float64_t fp64_log2( float64_t A );

The fp64_log2() function returns the base 2 logarithm of A.
log2(A) = log(A) / log(2).

(double) long

float64_t fp64_long_to_float64( float64_t A );

Alias to fp64_int32_to_float64, see there.

lrint

long fp64_lrint (float64_t A);

The fp64_lrint() function rounds A to the nearest integer, rounding the
halfway cases to the even integer direction. (That is both 1.5 and
2.5 values are rounded to 2). This function is similar to rint()
function, but it differs in type of return value and in that an
overflow is possible.
Return:
The rounded long integer value. If A is infinite, NaN or an overflow
was, this realization returns the LONG_MIN value (0x80000000).

Examples:
fp64_lrint(1.25) --> 1L
fp64_lrint(1.5) --> 2L
fp64_lrint(2.5) --> 2L
fp64_lrint(2.75) --> 3L
fp64_lrint(3.5) --> 4L
fp64_lrint(-1.25) --> -1L
fp64_lrint(-1.5) --> -2L
fp64_lrint(-2.5) --> -2L
fp64_lrint(-2.75) --> -3L
fp64_lrint(-3.5) --> -4L

The following rules apply:

caseAfp64_lrint(A)
1NaNLONG_MIN (0x80000000)
2+/- InfLONG_MIN (0x80000000)
3+/- 00L
4|A|>=2^31LONG_MIN (0x80000000)
50 < |A|<= 0.50L
60.5 < |A|< 1.0+/- 1L
71.0 <=|A|< 2^31 trunc(x) if (|x|-trunc(|x|)) < 0.5
trunc(x+sign(x)) if (|x|-trunc(|x|)) >= 0.5

lround

long fp64_lround (float64_t x);

The fp64_lround() function rounds x to the nearest integer, but rounds
halfway cases away from zero (instead of to the nearest even integer).
This function is similar to round() function, but it differs in
type of return value and in that an overflow is possible.
Return:
The rounded long integer value. If x is infinite, NaN or an overflow
was, this realization returns the LONG_MIN value (0x80000000).

Examples:
fp64_lround(1.1) --> 1L
fp64_lround(1.5) --> 2L
fp64_lround(-1.1) --> -1L
fp64_lround(-1.5) --> -2L

The following rules apply:

caseAfp64_lrint(A)
1NaNLONG_MIN (0x80000000)
2+/- InfLONG_MIN (0x80000000)
3+/- 00L
4|A|>=2^31LONG_MIN (0x80000000)
50 < |A|< 0.50L
60.5 <= |A|< 1.0+/- 1L
71.0 <=|A|< 2^31 trunc(x) if (|x|-trunc(|x|)) < 0.5
trunc(x+sign(x)) if (|x|-trunc(|x|)) >= 0.5

modf

float64_t fp64_modf (float64_t x, float64_t *iptr);

The fp64_modf() function breaks the argument x into an integral part and a fractional part, each of which has the same sign as x. The integral part
is stored in iptr. This implementation skips writing by zero pointer.

Examples:
modf(123.45) makes 0.45 (return value) + 123.0 (stored in *iptr)

The following rules apply:

casexfp64_modf(x)*iptr
1NaNNaNNaN
2InfInf0.0
30.00.00.0
4|x| > 2^530.0x
5|x| < 1.0x0.0

mul (*)

fp64 fp64_mul( fp64 A, fp64 B );

Multiplies two 64 bit floating point numbers and rounds result to a 64bit floating point number.

Examples:
modf(123.45) makes 0.45 (return value) + 123.0 (stored in *iptr)

The following rules apply:

caseABfp64_mul(A,B)
1NaNanyNaN
2anyNaNNaN
3Inf0.0NaN
40.0InfNaN
5Inf!= 0Inf
6!= 0InfInf

neg ( -x )

float64_t fp64_neg ( float64_t A );

Returns -A. Also works for special cases (NaN, +Inf, -Inf), subnormal numbers and +0 and -0.

pow

float64_t fp64_pow(float64_t x, float64_t y);

The fp64_pow() function returns the value of x raised to the power of y. The following rules apply:

casexyfp64_pow(x,y)
1any01.0 (includes x = NaN or Inf or 0)
2+1.0any1.0 (includes y = NaN or Inf)
3any+1.0x (includes x = NaN or Inf)
4ax < 0integer > 0x^y
4bx < 0anyNaN, if y is not a positive integer
5x > 0anyx^y

pow10

float64_t fp64_pow10 (float64_t x);

The fp64_exp10() function returns the value of 10 raised to the power of x, i.e. 10^x. It is an alias to fp64_exp10(x).

round

float64_t fp64_round( float64_t x );

Rounds x upwards to the nearest integer, but rounds halfway cases away from 0.

Examples: 
fp64_round(1.1) --> 1.0
fp64_round(1.5) --> 2.0
fp64_round(-1.1) --> -1.0
fp64_round(-1.5) --> -2.0

The following rules apply:

casexfp64_round(x)
1NaN NaN
2+/- Inf+/- Inf
3+/- 0+/- o
4 |x| >= 2^52 x
5 0 < |x| < 0.5 0.0
6 0.5 <= |x| < 1 +/- 1.0
71 <= |x| <= 2^52trunc(x) if (|x|-trunc(|x|)) < 0.5
trunc(x+sign(x)) if (|x|-trunc(|x|)) >= 0.5

scalbln

float64_t fp64_scalbln (float64_t x, long n);

fp64_scalbln behaves identical to fp64_ldexp() or fp64_scalbn,
but can be called with n being of type long instead of int.

Available with release 1.1.20 onwards.

scalbn

float64_t fp64_scalbn (float64_t x, int n);

fp64_scalbn is an alias to fp64_ldexp(), see there. It returns x * 2n.

Available with release 1.1.20 onwards.

(double) float

float64_t fp64_sd (float A);

Converts a float32 to the float64 representing the same number. As float64_t fully includes all values of float, no error or truncation occurs.

signbit

int fp64_signbit (float64_t x);

The fp64_signbit() function returns a nonzero value if the value of x has
its sign bit set. This is not the same as `x < 0.0′, because IEEE 754
floating point allows zero to be signed. The comparison `-0.0 < 0.0′
is false, but `fp64_signbit (-0.0)’ will return a nonzero value.

This implementation returns 1 if sign bit is set. This corresponds
to builtin GCC realization for float.

sin

float64_t fp64_sin( float64_t phi );

Returns the sine of phi. The following special cases apply:

casexfp64_sin(x)
1NaNNaN
2+INFNaN
3-INFNaN

sinh

float64_t fp64_sinh( float64_t x);

The fp64_sinh() function returns the hyperbolic sine of x, which is
defined mathematically as (exp(x) – exp(-x)) / 2.

sqrt

float64_t fp64_sqrt (float64_t);

Square root function. The following special cases apply:

sqrt(NaN) = NaN
sqrt(+Inf) = +Inf
sqrt(-Inf) = NaN
sqrt(+-0) = +-0

Be especially aware of the last special case: fp64_sqrt(-0) = -0. This is fully compliant to IEEE 754 standard, see Wikipedia, but might cause trouble in your code if you are relying on the result always beeing positive.

square

float64_t fp64_square (float64_t A);

The fp64_square() function returns square of A.

strtod

float64_t fp64_strtod( char *str, char **endptr );

converts a string to a number, handles also NaN, +INF, -INF
a valid number (non NaN or INF) can be expressed by the
following regex: [+-]?[0-9]+\.?[0-9]*([eE][+-]?[0-9]+)?

Returns the identified number as result, and *endptr contains pointer to last parsed position in string str.

sub ( – )

float64_t fp64_sub( float64_t A, float64_t B );

Subtracts two 64 bit floating point numbers and rounds result to a 64bit floating point number. The following special cases apply:

caseABfp64_sub(A,B)
1NaN any NaN
2anyNaNNaN
3a+Inf-Inf+Inf
3b+Inf+InfNaN
3c-Inf-InfNaN
3d-Inf+Inf-Inf
4InfanyInf
5anyInf-Inf
60any-any
7any0any

tan

float64_t fp64_tan( float64_4 phi );

Returns the tangent of phi. The following special cases apply:

tan(NaN) = NaN
tan(+Inf) = NaN
tan(-Inf) = NaN

tanh

float64_t fp64_tanh (float64_t x);

The fp64_tanh() function returns the hyperbolic tangent of x, which is
defined mathematically as sinh(x) / cosh(x).

fp64_to_decimalExp

char *fp64_to_decimalExp( float64_t x, uint8_t maxDigits, uint8_t expSep, int16_t *exp10 )

converts a number to a string with maxDigits of significand.

parameters:
x                    number x to convert in float64_t format
maxDigits  maximum number of digits in significand
expSep         flag to store significand and exponent seperately
exp10            if != NULL, store exponent base 10 here

NOTE: this function supports conversion of up to 17 digits. However, accuracy of IEEE754 is only 52 bit which is 15-16 decimal digits!

WARNING: function returns a pointer to a static temporary scratch area which might be used also for other functions. The returned string might become invalid/scrambled if one of the other fp64_ functions will be called. So copy the result to some other allocated memory that you have under control before calling further fp64lib-routines.

(int)

int fp64_to_int16( float64_t A );

The fp64_to_int16() function converts A to the signed integer value,
rounding towards 0, the fractional part is lost. No saturation.
Only when called in assembly language: Besides a normal 16-bits value, the carry is returned as extra error flag.

The following rules apply:

caseACarryfp64_to_int16 (A)
1NaN 10x0000
2Inf1 0x0000
3|A|>=2^151 0x0000
40<|A|<1.00 0x0000
5|A|<2^150(int) A

(long int)

long fp64_to_int32( float64_t A );

The fp64_to_int32() function converts A to the signed integer value,
rounding towards 0, the fractional part is lost. No saturation.
Only when called in assembly language: Besides a normal 32-bits value, the carry is returned as extra error flag.

The following rules apply:

caseACarry fp64_to_int32 (A)
1NaN 10x00000000
2Inf1 0x00000000
3|A|>=2^311 0x00000000
40<|A|<1.00 0x00000000
5|A|<2^310(long) A

(long long int)

long long fp64_to_int64( float64_t A );

The fp64_to_int64() function converts A to the signed integer value,
rounding towards 0, the fractional part is lost. No saturation.
Only when called in assembly language: Besides a normal 64-bits value, the carry is returned as extra error flag.

The following rules apply:

caseACarry fp64_to_int64 (A)
1NaN 10x0000000000000000
2Inf1 0x0000000000000000
3|A|>=2^6310x0000000000000000
40<|A|<1.00 0x0000000000000000
5|A|<2^630(long long) A

(char)

char fp64_to_int8( float64_t A );

The fp64_to_int8() function converts A to the signed integer value,
rounding towards 0, the fractional part is lost. No saturation.
Only when called in assembly language: Besides a normal 8-bits value, the carry is returned as extra error flag.

The following rules apply:

caseACarry fp64_to_int8 (A)
1NaN 10x00
2Inf10x00
3|A|>=2^710x00
40<|A|<1.00 0x00
5|A|<2^70(char) A

fp64_to_string

char *fp64_to_string(float64_t x, uint8_t max_chars, uint8_t max_zeroes);

converts the float64 to the decimal representation of the number x. fp64_to_string adjusts the number of decimal digits so that the result
will fit into a string with max_chars characters. However, a longer string
will be returned if the minimum representation will not fit into max_chars.
Minimum representation is “mESn[nn]” for X > 0 else “-mESn[nn]”, so at least 4 to 7 characters are needed.

parameters:
x:                        number to convert in float64_t format
max_chars:   maximum space for result
max_zeroes: use “s0.mmmmmm” when result has less than this # of 0s

WARNING: function returns a pointer to a static temporary scratch area which might be used also for other functions. The returned string might become invalid/scrambled if one of the other fp64_ functions will be called. So copy the result to some other allocated memory that you have under control before calling further fp64__ routines.

The following rules apply:

casexfp64_to_string(x)
1NaN“NaN”
2+Inf“+INF”
3-Inf“-INF”
4|x|<1“s0.mmmmmm” representation without exponent if x can be displayed with less than max_zeroes “0” after “0.”
leading sign s only for x < 0
else exponential form is used “sm.mmmmmESnnn”
5log10(|x|)<max_chars“smmm.mmm” representation without exponent
6all other cases“sm.mmmmmESn” exponential form is used
leading sign s only for x < 0
exponent “Snnn” has always a sign S (“+” or “-“) and one digit to three digits nnn for the exponent

NOTE: this function supports conversion of up to 17 digits. However, accuracy of IEEE754 is only 52 bit, which is 15-16 decimal digits! Therefore, in no case more than 17 digits of precision are generated.

(unsigned int)

unsigned int fp64_to_uint16( float64_t A );

The fp64_to_uint16() function converts A to the unsigned integer value,
rounding towards 0, the fractional part is lost. No saturation.
Negative input is permissable (like GCC/x86).
Only when called in assembly language: Besides a normal 16-bits value, the carry is returned as extra error flag.

The following rules apply:

caseACarry fp64_to_uint16 (A)
1NaN 10x0000
2Inf1 0x0000
3|A|>=2^161 0x0000
40 < |A| <1.00 0x0000
50 < A < 2^160(unsigned int) A
6-2^16 < A < 00-((unsigned int) (-A)

(unsigned long)

unsigned long fp64_to_uint32( float64_t A );

The fp64_to_uint32() function converts A to the unsigned integer value,
rounding towards 0, the fractional part is lost. No saturation.
Negative input is permissable (like GCC/x86).
Only when called in assembly language: Besides a normal 32-bits value, the carry is returned as extra error flag.

The following rules apply:

caseACarry fp64_to_uint32 (A)
1NaN 10x00000000
2Inf1 0x00000000
3|A|>=2^321 0x00000000
40 < |A| <1.00 0x00000000
50 < A < 2^320(unsigned long) A
6-2^32 < A < 00-((unsigned long) (-A)

(unsigned long long)

unsigned long long fp64_to_uint64( float64_t A );

The fp64_to_uint64() function converts A to the unsigned integer value,
rounding towards 0, the fractional part is lost. No saturation.
Negative input is permissable (like GCC/x86).
Only when called in assembly language: Besides a normal 64-bits value, the carry is returned as extra error flag.

The following rules apply:

caseACarry fp64_to_uint64 (A)
1NaN 10x0000000000000000
2Inf1 0x0000000000000000
3|A|>=2^641 0x0000000000000000
40 < |A| <1.00 0x0000000000000000
50 < A < 2^640(unsigned long long) A
6-2^64 < A < 00-((unsigned long long) (-A)

(unsigned char)

unsigned char fp64_to_uint8( float64_t A );

The fp64_to_uint8() function converts A to the unsigned integer value,
rounding towards 0, the fractional part is lost. No saturation.
Negative input is permissable (like GCC/x86).
Only when called in assembly language: Besides a normal 64-bits value, the carry is returned as extra error flag.

The following rules apply:

caseACarryfp64_to_uint64 (A)
1NaN 10x00
2Inf1 0x00
3|A|>=2^81 0x00
40 < |A| <1.00 0x00
50 < A < 2^80(unsigned char) A
6-2^8 < A < 00-((unsigned char) (-A)

trunc

float64_t fp64_trunc( float64_t A );

Rounds A to the nearest integer not larger in absolute value,
by cutting the noninteger part ( = setting the fractional part to 0).
This is effectively the same as rounding A towards 0.

Examples: 
fp64_trunc(1.9) --> 1.0
fp64_trunc(-1.9) --> -1.0

The following rules apply:

caseAfp64_trunc(A)
1NaN NaN
2+Inf+Inf
3-Inf-Inf
40.00.0
5-0.0-0.0
6|A| >= 2^52A
70 < |A| < 10.0
81 <= |A| <= 2^52A – fractional_part(A)

(double) unsigned int

float64_t fp64_uint16_to_float64( uint16_t x );

Convert an unsigned 16-bit integer to float64_t. Overflow cannot occur.

Available with release 1.08 onwards.

(double) long long

float64_t fp64_uint64_to_float64( unsigned long long x );

Convert an unsigned 64-bit integer (unsigned long long) to float64_t.
Overflow cannot occur, but loss of precision, if abs(x) > 2^53