I've created my own fixed-type integer types and the library works fine with many compilers and platforms, the only problem left to solve is to convert from built-in float-point types to my types.
The float-point types may have small mantissa but along with exponent it may have big value so if i choose to cast float
, double
, or long double
say to long long
or unsigned long long
a truncation may occur.
If the compiler use IEEE-754 specification it'll be easy to extract mantissa and exponent, but what if the compiler use some other format.
So, my question: is there any generic algorithm that allows me to extract the full value from a float-point using only the language features?
thanks