Palm OS Cobalt supports IEEE-754 single and double precision floating-point numbers declared with the C types float
and double
. Numbers of type float
occupy four bytes and have an effective range of 1.17549e-38 to 3.40282e+38. Numbers of type double
occupy eight bytes and have an effective range of
2.22507e-308 to 1.79769e+308. Limited operations are also permitted on values of type long double.
You can use basic arithmetic operations to add, subtract, multiply, and divide numbers of type float
and double
. Higher-level functions such as those in the standard C header file math.h
are not part of the core OS; you must either write them yourself, or you must employ a third-party math library.
The standard IEEE-754 special "non-number" values of NaN (not a number), +INF (positive infinity), and -INF (negative infinity) are generated as appropriate if you perform an operation that produces a result outside the range of numbers that can be represented. For instance, dividing a positive number by 0 returns +INF.
The Float Manager contains functions that convert double-precision floating-point numbers to and from various other formats: 32- and 64-bit signed and unsigned integers, as well as floating point values of differing lengths. It also provides a set of basic comparison functions that can be used with values of type double
and float
. Finally, it supplies a set of functions that you can use to add, subtract, multiply, and divide values of type float and double.
Two of the supplied mathematical operations are special: FlpCorrectedAdd()
and FlpCorrectedSub()
let you add or subtract double values, optionally correcting for least-significant-bit errors when the result should be zero but instead is very close to zero.
In the rare event that you need to work with the binary representation of a double
, you can use FlpBase10Info()
to obtain the mantissa, exponent, and sign (all in base 10) of a double value. If you only need the exponent, you can use FlpGetExponent()
instead.
See Chapter 28, "Float Manager," for complete reference information on the functions and macros that make up the Float Manager.