You can select a floating-point library and the method of accessing floating-point routines by setting options in PWB or by specifying command-line options to CL. You can choose between the emulator, alternate, or math coprocessor library. You can also access the floating-point routines by issuing a function call (or calls) or by generating inline 80x87 instructions to execute the floating-point operation. The smallest and the fastest floating-point math option is the inline math coprocessor package because the compiler generates true 80x87 coprocessor instructions. If, however, you cannot depend on the target computer having a coprocessor, you must use either the emulator or alternate math options.
To specify floating-point options on the CL command line, you must specify an option from the list in Table 7.4. You specify these options to CL starting with the floating-point option string /FP.
Based on the floating-point option and the memory-model option you choose, the compiler embeds a library name in the object file that it creates. This library is then considered the default library; that is, the linker searches in the standard places for a library with that name. If it finds a library with that name, the linker uses the library to resolve external references in the object file being linked. Otherwise, it displays a message indicating that it could not find the library.
This mechanism allows the linker to automatically link object files with the appropriate library. However, you can link with a different library in some cases. See Table 7.4 and “Library Considerations for Floating-Point Options,” for more information about linking with different libraries.
Table 7.4 summarizes the floating-point options and their effects. These options are described in detail in the following sections.
Table 7.4 Summary of Floating-Point Options
Option for CL for PWB |
Combined Use of Method |
Effect |
Coprocessor |
Libraries Selected |
/FPi Inline Emulation | Inline | Default; larger than /FPi87, but can work without a coprocessor; most efficient way to get maximum precision without a coprocessor | Uses coprocessor if present1 | mLIBCE.LIB2 | |
/FPi87 Inline Math Coprocessor | Inline | Smallest and fastest option available with a coprocessor | Requires coprocessor | mLIBC7.LIB | |
/FPc Calls to Emulator | Calls | Slower than /FPi, but allows use of alternate math library at link time | Uses coprocessor if present1 | mLIBCE.LIB2,3 | |
/FPc87 Calls to Math Coprocessor | Calls | Slower than /FPi87, but allows use of alternate math library at link time | Requires coprocessor unless library changed at link time5 | mLIBC7.LIB3,4 | |
/FPa Alternate Math | Calls | Fastest and smallest option available without a coprocessor, but sacrifices some accuracy for speed | Ignores coprocessor, mLIBCA.LIB2,4 |
1 Use of the coprocessor can be suppressed by setting NO87.
2 Can be linked explicitly with mLIBC7.LIB at link time.
3 Can be linked explicitly with mLIBCA.LIB at link time.
4 Can be linked explicitly with mLIBCE.LIB at link time.
5 Use of the coprocessor can be suppressed by setting NO87 if you change to the emulator library at link time.
Optimizations such as constant propagation and constant subexpression elimination can cause some expressions to be evaluated at compile time. Such evaluations always use IEEE format and are unaffected by the floating-point option you choose. For more information about optimizing, see Chapter 1, “Optimizing Your Programs.”
Summary: You can specify floating-point options in the Programmer's WorkBench.
To specify floating-point options when using the Programmer's WorkBench, pull down the Language Options submenu of the Options menu. From that menu, open the C or C++ Compiler Options dialog box. From that dialog box, open the Additional Release Options dialog box and select one of the following floating-point math options:
Option | Effect |
Emulation Calls | Generates calls; makes emulator math library the default (/FPc) |
80x87 Calls | Generates calls; makes math coprocessor library the default (/FPc87) |
Fast Alternate Math | Generates calls; makes alternate math library the default (/FPa) |
Inline Emulation | Generates inline instructions; makes emulator math library the default (/FPi); this is the default option |
Inline 80x87 Instructions | Generates inline instructions; selects math coprocessor library (/FPi87) |