-
Notifications
You must be signed in to change notification settings - Fork 12
Added Functions
All three added routines return the scaled floating point result from the most recent operation. A scaled result can be returned from any operation that creates a result value, such as the arithmetic and rounding operations. Comparison operations do not generate a floating point result; return of a scaled floating point result is not possible.
float32_t f32_scaledResult(int_fast16_t scaleFactor)
float64_t f64_scaledResult(int_fast16_t scaleFactor)
float128_t f128_scaledResult(int_fast16_t scaleFactor)
The argument is the scale factor to be applied to the result in addition to the normal bias for the target precision. There is no range testing of the scale factor. While any scaling factor may be used, unpredictable results occur with use of other than those scale factors appropriate for the returned precision and operation being performed.
For a brief layman's discussion of scaled results, please see Scaled Results in this Wiki.
For the authoritative source, please refer to the IBM z/Architecture Principles of Operation, SA22-7832-10, Chapter 19, Binary Floating Point Instructions, for details on scaled results and appropriate scale factors for different instructions and target precisions. In particular, Figure 19-8 (part 2 of 2) on page 19-9 of this reference manual specifies when scaled results are to be returned and how results should be scaled.
These routines are used for two purposes:
- To return a scaled result in the same precision as the original result was to be returned in.
- To return a scaled result in the source operand precision, used for Load Rounded.
Emulation of Load Rounded is performed using the Softfloat routines f64_to_32(), f128_to_64(), and f128_to_32(). If, for example, a call to f64_to_32() creates a requirement for Load Rounded to return a scaled result, a call to f64_scaledResult() is used to obtain it. Coding for LEDBR/LEDBRA in ieee.c in Hercules provides an example of this use of scaled results.
Arithmetic instruction emulation code in ieee.c provides examples for the correct use of fxx_scaledResult().
If, after application of the target precision's bias and the scaling factor, the resulting exponent is too large or small for the target precision, a Signaling NaN with payload 0xDEAD is returned instead of the scaled result. A signalling NaN can returned if and only if these functions are called with scale factors other than those documented in Figure 19-8 (Part 2 of 2) on page 19-9 of SA22-7382-10.
This Wiki Copyright © 2016 by Stephen R. Orso. This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.