Floating-point types

On CommonPoint platforms, the C++ types float and double are just the single and double types of the IEEE floating-point standards. The type float offers about 7 decimal digits of precision, and double about 15 digits. CommonPoint platforms also support a long double type, though its features vary significantly with the underlying processor.

Two types defined in the CommonPoint headers enable you to program efficiently yet portably. The type float_t is the platform's most efficient type at least as wide as float; it may be float itself, double, or long double according to the underlying processor. The type float_t is float on PA-RISC, double on PowerPC, and long double on X86.

Similarly, double_t is a platform's most efficient type at least as wide as double; it will be double except on platforms whose underlying processor evaluates all floating-point expressions to long double, in which case it will be long double. The type double_t is double on PA-RISC and PowerPC, and is long double on X86.

TIP Always use double_t temporary variables when you need the precision and range of the double type; use float_t temporary variables when you need the precision and range of the float type. This is a portable technique for requesting a platform's most efficient types. Only rarely should you need exactly the range and precision of types double and float.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker