Conversion functions

As fp64lib is an add-on library, getting data into the float64_t datatype and out of it is a key. The following will not work:

float64_t x = 1.0;
float64_t y = (float64_t) 3.141;
float64_t z = 10;

The above statements will all load some data into x, y, and z – but it will definitely not be 1.0, 3.141 or 10! Instead, use the following code that will work correctly:

float64_t x = fp64_sd(1.0);
float64_t y = fp64_sd(3.141);
float64_t z = fp64_uint32_to_float64(10);

fp64lib provides quite a number of functions to convert data to all native C data types: more...

convert to float64_tconvert from float64_t
long longfp64_int64_to_float64()fp64_to_int64()
unsigned
long long
fp64_uint64_to_float64() fp64_to_uint64()
long fp64_int32_to_float64()
fp64_long_to_float64()
fp64_to_int32()
unsigned
long
fp64_uint32_to_float64() fp64_to_uint32
int fp64_int32_to_float64() * fp64_to_int16()
unsigned
int
fp64_uint32_to_float64() * fp64_to_uint16()
char fp64_int32_to_float64() *fp64_to_int8()
unsigned
char
fp64_uint32_to_float64() *fp64_to_uint8()
floatfp64_sd()fp64_ds()
char*fp64_strtod()fp64_to_decimalExp()
fp64_to_string()

*For these data types, no special routine was needed to implement, as the compiler automatically extends (“coerces”) the smaller data type into a signed/unsigned long. So basically the following two lines are identical:

float64_t x = fp64_int32_to_float64( 17 );
float64_t x = fp64_int32_to_float64( (long) 17 );

So you can go with the short version.