double f(float x) {...} double g(float y, float z) { return f(y + z); }
f
? On a platform like X86 that operates internally to a format wider than float, the sequence might be:
y
and z
to long double.f
.f
, convert the parameter to long double in a register for use.
For almost all numerical programs, strict adherence to the types specified by declared variables is unnecessary and possibly wasteful. Strict type adherence produced a less accurate result in the case of y = y + (x * x)
and a slower computation in the case of f(y + z)
. However, some algorithms do depend critically on the rounding of intermediate values to a specified precision.
FPCE defines compiler pragmas for these situations:
NOTE
For most portable results, use intermediate values of type float_t and double_t. They allow the compiler to do what's best for the hardware. In the (rare) circumstance that a float or double value must be rounded to exactly the precision of the type, use an explicit cast.
Setting these pragmas to on
can improve a program's performance. But there is no guarantee that a compiler will honor them by widening the relevant data. On CommonPoint platforms, the constructs float_t and double_t capture the spirit of fp_wide_variables in a more explicit and portable fashion.
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Generated with WebMaker