Skip to content

Repo sync for protected branch #4802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions docs/c-runtime-library/reference/fegetround-fesetround2.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ api_type: ["DLLExport"]
topic_type: ["apiref"]
f1_keywords: ["fegetround", "fesetround", "fenv/fegetround", "fenv/fesetround"]
helpviewer_keywords: ["fegetround function", "fesetround function"]
ms.assetid: 596af00b-be2f-4f57-b2f5-460485f9ff0b
---
# `fegetround`, `fesetround`

Expand All @@ -18,10 +17,7 @@ Gets or sets the current floating-point rounding mode.

```C
int fegetround(void);

int fesetround(
int round_mode
);
int fesetround(int round_mode);
```

### Parameters
Expand Down Expand Up @@ -51,30 +47,29 @@ The default behavior of `FE_TONEAREST` is to round results midway between repres
The current rounding mode affects these operations:

- String conversions.

- The results of floating-point arithmetic operators outside of constant expressions.

- The library rounding functions, such as `rint` and `nearbyint`.

- Return values from standard library mathematical functions.

The current rounding mode doesn't affect these operations:

- The `trunc`, `ceil`, `floor`, and `lround` library functions.

- Floating-point to integer implicit casts and conversions, which always round towards zero.

- The results of floating-point arithmetic operators in constant expressions, which always round to the nearest value.

To use these functions, you must turn off floating-point optimizations that could prevent access by using the `#pragma fenv_access(on)` directive prior to the call. For more information, see [`fenv_access`](../../preprocessor/fenv-access.md).

> [!IMPORTANT]
> Prior to Windows 10 version 14393, `fenv.h` defined `FE_UPWARD = 0x0100` and `FE_DOWNWARD = 0x0200`. In Windows version 14393, this header was updated to address a bug in which some APIs would interpret `FE_UPWARD` as `FE_DOWNWARD`, and vice-versa. Starting in Windows version 14393, `FE_UPWARD = 0x0200` and `FE_DOWNWARD = 0x0100`, reversing their previous values.
> If you compiled your app against an old Windows SDK version (this issue depends on SDK version, not OS version or VS version) you might encounter this issue. Update your app to target the latest Windows SDK so that the definitions of `FE_UPWARD` and `FE_DOWNWARD` are consistent with the Windows implementation. If you can't update your app to target a later Windows SDK, you can define `FE_UPWARD` as `0x0100` and `FE_DOWNWARD` as `0x0200` in your code.

## Requirements

| Function | C header | C++ header |
|---|---|---|
| **`fegetround`**, **`fesetround`** | \<fenv.h> | \<cfenv> |
| **`fegetround`**, **`fesetround`** | `<fenv.h>` | `<cfenv>` |

For more compatibility information, see [Compatibility](../compatibility.md).
For more information, see [Compatibility](../compatibility.md).

## See also

Expand Down