Floating point precision control (Delphi for x64)

From RAD Studio
Jump to: navigation, search

Go Up to Delphi Compiler Directives (List) Index


Type

Switch

Syntax

{$EXCESSPRECISION ON}, {$EXCESSPRECISION OFF}

Default

{$EXCESSPRECISION ON}

Scope

Local

Remarks

The $EXCESSPRECISION directive controls the way the compiler treats intermediate results of single-precision (32 bit) floating-point expressions. $EXCESSPRECISION is specific to x64 target CPU of the Delphi compiler.

By default, all x64 arithmetic operations and expressions involving only single-precision floating-point values retain high precision by storing intermediate results as double-precision (64 bit) floating-point values. As a consequence, these operations are slower than double-precision floating-point operations (the compiled code converts Single values to Double on each operation).

If the speed of execution is the primary concern, mark the code in question with the {$EXCESSPRECISION OFF} directive to disable the use of intermediate double-precision values; otherwise the default directive ({$EXCESSPRECISION ON}) is recommended to improve the precision of the resulting value.

For the x86 target CPU, the $EXCESSPRECISION directive has no effect. The code generated for this platform uses the FPU (floating-point unit), which stores the intermediate results of any type of operation as extended-precision (80 bit) floating-point values.

See Also