Share via


/Op   (Improve Float Consistency)

OverviewHow Do ICompiler Options

Feature Only in Professional and Enterprise Editions   Code optimization is supported only in Visual C++ Professional and Enterprise Editions. For more information, see .

The Improve Float Consistency (/Op[–]) option improves the consistency of floating-point tests for equality and inequality by disabling optimizations that could change the precision of floating-point calculations. (To find this option in the development environment, click Settings on the Project menu. Then click the C/C++ tab, and click Optimizations in the Category box. Under Optimizations, click Customize.)

By default, the compiler uses the coprocessor’s 80-bit registers to hold the intermediate results of floating-point calculations. This increases program speed and decreases program size. However, because the calculation involves floating-point data types that are represented in memory by less than 80 bits, carrying the extra bits of precision (80 bits minus the number of bits in a smaller floating-point type) through a lengthy calculation can produce inconsistent results.

With /Op, the compiler loads data from memory prior to each floating-point operation and, if assignment occurs, writes the results back to memory upon completion. Loading the data prior to each operation guarantees that the data does not retain any significance greater than the capacity of its type.

A program compiled with /Op may be slower and larger than one compiled without /Op.

Note   The /Op option disables inline generation of floating-point functions. The standard run-time library routines are used instead. For more information, see the /Oi option.

If you select the Disable Language Extensions (/Za) option in order to compile for ANSI compatibility, the use of /Op is implied. The use of /Op improves the consistency of floating-point tests for equality and inequality. The nature of the improved consistency provides for strict ANSI conformance and is the only situation under which /Op is selected by default. The /Op– option is provided to override the default selection of /Op with /Za. Specify /Op– on the command line (or in the Common|Project|Source File Options text box) after /Za, to disable /Op.

See Also   IEEE Floating-Point Representation and Microsoft Languages, Why Floating Point Numbers May Lose Precision