Skip to content

Commit 41d046e

Browse files
authored
Merge pull request #3802 from corob-msft/docs/corob/cpp-docs-3369
Address /fp sample code issue cpp-docs 3369
2 parents ea54848 + b3ca43e commit 41d046e

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

docs/build/reference/fp-specify-floating-point-behavior.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: /fp (Specify floating-point behavior)"
33
title: "/fp (Specify floating-point behavior)"
4-
ms.date: 07/15/2021
4+
ms.date: 09/29/2021
55
f1_keywords: ["VC.Project.VCCLCompilerTool.floatingPointModel", "VC.Project.VCCLWCECompilerTool.FloatingPointExceptions", "/fp", "VC.Project.VCCLWCECompilerTool.floatingPointModel", "VC.Project.VCCLCompilerTool.FloatingPointExceptions"]
66
helpviewer_keywords: ["-fp compiler option [C++]", "/fp compiler option [C++]"]
77
ms.assetid: 10469d6b-e68b-4268-8075-d073f4f5d57e
@@ -179,13 +179,12 @@ int main()
179179
b = (f2 == f2);
180180
c = (f1 - f1);
181181
d = (f2 - f2);
182+
e = (gf0 / f3);
182183
printf("INFINITY == INFINITY : %d\n", a);
183184
printf("NAN == NAN : %d\n", b);
184185
printf("INFINITY - INFINITY : %f\n", c);
185186
printf("NAN - NAN : %f\n", d);
186-
187-
e = gf0 / abs(f3);
188-
printf("std::signbit(-0.0/-INFINITY): %d\n", std::signbit(c));
187+
printf("std::signbit(-0.0/-INFINITY): %d\n", std::signbit(e));
189188
return 0;
190189
}
191190
```
@@ -196,8 +195,8 @@ When compiled by using `/O2 /fp:precise` or `/O2 /fp:strict` for x86 architectur
196195
INFINITY == INFINITY : 1
197196
NAN == NAN : 0
198197
INFINITY - INFINITY : -nan(ind)
199-
NAN - NAN : -nan(ind)
200-
std::signbit(-0.0/-INFINITY): 1
198+
NAN - NAN : nan
199+
std::signbit(-0.0/-INFINITY): 0
201200
```
202201

203202
When compiled by using `/O2 /fp:fast`** for x86 architecture, the outputs aren't consistent with IEEE-754:
@@ -212,7 +211,7 @@ std::signbit(-0.0/-INFINITY): 0
212211

213212
### Floating-point algebraic transformations
214213

215-
Under **`/fp:precise`** and **`/fp:strict`**, the compiler doesn't perform mathematical transformations unless the transformation is guaranteed to produce a bitwise identical result. The compiler may make such transformations under **`/fp:fast`**. For example, the expression `a * b + a * c` in the sample function `algebraic_transformation` may be compiled into `a * (b + c)` under **`/fp:fast`**. Such transformations aren't done under **`/fp:precise`** or **`/fp:strict`**, and the compiler generates `a * b + a * c`.
214+
Under **`/fp:precise`** and **`/fp:strict`**, the compiler doesn't do any mathematical transformation unless the transformation is guaranteed to produce a bitwise identical result. The compiler may make such transformations under **`/fp:fast`**. For example, the expression `a * b + a * c` in the sample function `algebraic_transformation` may be compiled into `a * (b + c)` under **`/fp:fast`**. Such transformations aren't done under **`/fp:precise`** or **`/fp:strict`**, and the compiler generates `a * b + a * c`.
216215

217216
```cpp
218217
float algebraic_transformation (float a, float b, float c)

docs/sanitizers/error-stack-buffer-overflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Error: stack-buffer-overflow"
33
description: "Source examples and live debug screenshots for Stack buffer overflow errors."
4-
ms.date: 09/28/2021
4+
ms.date: 09/29/2021
55
f1_keywords: ["stack-buffer-overflow"]
66
helpviewer_keywords: ["stack-buffer-overflow error", "AddressSanitizer error stack-buffer-overflow"]
77
---

0 commit comments

Comments
 (0)