Skip to content

Latest commit

 

History

History
98 lines (83 loc) · 2.17 KB

fp-contract.md

File metadata and controls

98 lines (83 loc) · 2.17 KB
title ms.custom ms.date ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager translation.priority.ht
fp_contract | Microsoft Docs
11/04/2016
cpp-tools
article
vc-pragma.fp_contract
fp_contract_CPP
C++
pragmas, fp_contract
fp_contract pragma
15b97338-6680-4287-ba2a-2dccc5b2ccf5
12
corob-msft
corob
ghogen
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

fp_contract

Determines whether floating-point contraction will take place.

Syntax

#pragma fp_contract [ON | OFF]  

Remarks

By default, fp_contract is ON.

For more information on floating-point behavior, see /fp (Specify Floating-Point Behavior).

Other floating-point pragmas include:

Example

The code generated from this sample does not use the Fused Multiply Add (fma) instruction on Itanium processors. If you comment out #pragma fp_contract (off), the generated code will use the fma instruction.

// pragma_directive_fp_contract.cpp  
// compile with: /O2  
#include <stdio.h>  
#include <float.h>  
  
#pragma fp_contract (off)   
  
int main() {  
   double z, b, t;  
  
   for (int i = 0; i < 10; i++) {  
      b = i * 5.5;  
      t = i * 56.025;  
      _set_controlfp(_PC_24, _MCW_PC);  
  
      z = t * i + b;  
      printf_s ("out=%.15e\n", z);  
   }  
}  
out=0.000000000000000e+000  
out=6.152500152587891e+001  
out=2.351000061035156e+002  
out=5.207249755859375e+002  
out=9.184000244140625e+002  
out=1.428125000000000e+003  
out=2.049899902343750e+003  
out=2.783724853515625e+003  
out=3.629600097656250e+003  
out=4.587524902343750e+003  

See Also

Pragma Directives and the __Pragma Keyword