how can I extract the mantissa of a double
Solution 1:
In <math.h>
double frexp (double value, int *exp)
decompose VALUE in exponent and mantissa.
double ldexp (double value, int exp)
does the reverse.
To get an integer value, you have to multiply the result of frexp by FLT_RADIX exponent DBL_MANT_DIG (those are availble in <float.h>
. To store that in an integer variable, you also need to find an adequate type (often a 64 bits type)
If you want to handle the 128 bits long double some implementations provide, you need C99 frexpl to do the splitting and then you probably don't have an adequate integer type to store the full result.
Solution 2:
Many Linux systems have /usr/include/ieee754.h which defines bitfields for IEEE-format float, double and long double: you could trivially "port" it if necessary.