You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/preprocessor/fenv-access.md
+13-4Lines changed: 13 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
---
2
2
title: "fenv_access pragma"
3
-
ms.date: "08/29/2019"
3
+
description: "Describes the usage and effects of the fenv_access pragma directive. The fenv_access directive controls access to the floating-point environment at runtime."
@@ -15,9 +16,17 @@ Disables (**on**) or enables (**off**) optimizations that could change floating-
15
16
16
17
## Remarks
17
18
18
-
By default, **fenv_access** is **off**. If the compiler can assume that your code does not access or manipulate the floating-point environment, then it can perform many floating-point code optimizations. Set **fenv_access** to **on** to inform the compiler that your code accesses the floating-point environment to test status flags, exceptions, or to set control mode flags. The compiler disables these optimizations so that your code can access the floating-point environment consistently.
19
+
By default, **fenv_access** is **off**. The compiler assumes your code doesn't access or manipulate the floating-point environment. If environment access isn't required, the compiler can do more to optimize your floating-point code.
19
20
20
-
For more information on floating-point behavior, see [/fp (Specify Floating-Point Behavior)](../build/reference/fp-specify-floating-point-behavior.md).
21
+
Enable **fenv_access** if your code tests floating-point status flags, exceptions, or sets control mode flags. The compiler disables floating-point optimizations, so your code can access the floating-point environment consistently.
22
+
23
+
The [/fp:strict] command-line option automatically enables **fenv_access**. For more information on this and other floating-point behavior, see [/fp (Specify Floating-Point Behavior)](../build/reference/fp-specify-floating-point-behavior.md).
24
+
25
+
There are restrictions on the ways you can use the **fenv_access** pragma in combination with other floating-point settings:
26
+
27
+
- You can't enable **fenv_access** unless precise semantics are enabled. Precise semantics can be enabled either by the [float_control](float-control.md) pragma, or by using the [/fp:precise](../build/reference/fp-specify-floating-point-behavior.md) or [/fp:strict](../build/reference/fp-specify-floating-point-behavior.md) compiler options. The compiler defaults to **/fp:precise** if no other floating-point command-line option is specified.
28
+
29
+
- You can't use **float_control** to disable precise semantics when **fenv_access(on)** is set.
21
30
22
31
The kinds of optimizations that are subject to **fenv_access** are:
23
32
@@ -65,7 +74,7 @@ int main() {
65
74
out=9.999999776482582e-03
66
75
```
67
76
68
-
If you comment out `#pragma fenv_access (on)` from the previous sample, note that the output is differentbecause the compiler does compile-time evaluation, which does not use the control mode.
77
+
If you comment out `#pragma fenv_access (on)` from the previous sample, the output is different. It's because the compiler does compile-time evaluation, which doesn't use the control mode.
Copy file name to clipboardExpand all lines: docs/preprocessor/float-control.md
+46-23Lines changed: 46 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,7 @@
1
1
---
2
2
title: "float_control pragma"
3
-
ms.date: "08/29/2019"
3
+
description: "Describes the usage and effects of the float_control pragma directive. The float_control directive controls the state of floating-point precise semantics and exception semantics at runtime."
Specifies floating-point behavior, which can be **precise**, **strict**, or **except**. For more information, see [/fp (Specify Floating-Point Behavior)](../build/reference/fp-specify-floating-point-behavior.md). The setting can either be **on**or **off**.
22
+
**precise**, **on** | **off**, **push**\
23
+
Specifies whether to enable (**on**) or disable (**off**) precise floating-point semantics. For information on how this option differs from the similarly named **/fp:precise** compiler option, see the Remarks section. The optional **push**token tells the compiler to push the current setting for **float_control** on the internal compiler stack.
22
24
23
-
When **strict**, the settings for both **strict** and **except** are specified by the **on** or **off** setting. **except** can only be set to **on** when **precise** or **strict** is also set to **on**.
25
+
**except**, **on** | **off**, **push**\
26
+
Specifies whether to enable (**on**) or disable (**off**) floating-point exception semantics. For information on how this option differs from the similarly named **/fp:except** compiler option, see the Remarks section. The optional **push** token tells the compiler to push the current setting for **float_control** on the internal compiler stack.
24
27
25
-
If the optional **push**token is added, the current setting for**float_control** is pushed on to the internal compiler stack.
28
+
**except**can only be set to **on** when**precise** is also set to **on**.
26
29
27
30
**push**\
28
-
Push the current **float_control** setting on to the internal compiler stack
31
+
Pushes the current **float_control** setting on to the internal compiler stack.
29
32
30
33
**pop**\
31
-
Removes the **float_control** setting from the top of the internal compiler stack and makes that the new **float_control** setting.
34
+
Removes the **float_control** setting from the top of the internal compiler stack, and makes that the new **float_control** setting.
32
35
33
36
## Remarks
34
37
35
-
You cannot use **float_control** to turn **precise** off when **except** is on. Similarly, **precise** cannot be turned off when [fenv_access](../preprocessor/fenv-access.md) is on. To go from strict model to a fast model by using the **float_control** pragma, use the following code:
38
+
The **precise** and **except** options don't have exactly the same behavior as the [/fp](../build/reference/fp-specify-floating-point-behavior.md) compiler options of the same names. The **float_control** pragma only governs part of the floating-point behavior. It must be combined with [fp_contract](../preprocessor/fp-contract.md) and [fenv_access](../preprocessor/fenv-access.md) pragmas to recreate the **/fp** compiler options. The following table shows the equivalent pragma settings for each compiler option:
In other words, you must use several pragmas in combination to emulate the **/fp:fast**, **/fp:precise**, **/fp:strict**, and **/fp:except** command-line options.
49
+
50
+
There are restrictions on the ways you can use the **float_control** and **fenv_access** floating-point pragmas in combination:
51
+
52
+
- You can only use **float_control** to set **except** to **on** if precise semantics are enabled. Precise semantics can be enabled either by the **float_control** pragma, or by using the **/fp:precise** or **/fp:strict** compiler options.
53
+
54
+
- You can't use **float_control** to turn **precise** off when exception semantics are enabled, whether by a **float_control** pragma or a **/fp:except** compiler option.
55
+
56
+
- You can't enable **fenv_access** unless precise semantics are enabled, whether by a **float_control** pragma or a compiler option.
57
+
58
+
- You can't use **float_control** to turn **precise** off when **fenv_access** is enabled.
59
+
60
+
These restrictions mean the order of some floating-point pragmas is significant. To go from a fast model to a strict model using the **float_control** and related pragmas, use the following code:
0 commit comments