This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4563. Missing "round to nearest, ties away from zero" mode

Section: 17.3.4 [round.style] Status: New Submitter: Jan Schultke Opened: 2026-03-30 Last modified: 2026-04-04

Priority: Not Prioritized

View all other issues in [round.style].

View all issues with New status.

Discussion:

As discussed in LWG 4474(i) (approved for C++26), std::round_style is intended to be symmetrical with FLT_ROUNDS. LWG 4474(i) clarified that round_to_nearest corresponds to an FLT_ROUNDS value of 1, meaning "to nearest, ties to even".

Unfortunately, any implementation using the mode "to nearest, ties away from zero" (corresponding to an FLT_ROUNDS value of 4 and supported by ISO/IEC 60559 floating-point implementations) is forced to stop using round_to_nearest as a numeric_limits<float>::round_style constant due to stricter requirements for that enumerator. To prevent such implementations from resorting to a non-standard enumerator, a new enumerator is needed.

The name should be inspired by C23 macros such as FE_TONEARESTFROMZERO.

See also ISO/IEC 9899:2024 ยง5.2.5.3 paragraph 23

Proposed resolution:

This wording is relative to N5032 after application of LWG motion 1 (See LWG Motion 1-#4474).

  1. Modify 17.3.4 [round.style] as indicated:

    namespace std {
      enum float_round_style {
        round_indeterminate = -1,
        round_toward_zero = 0,
        round_to_nearest = 1,
        round_toward_infinity = 2,
        round_toward_neg_infinity = 3,
        round_to_nearest_from_zero = 4
      };
    }
    

    -1- The rounding mode for floating-point arithmetic is characterized by the values:

    • (1.1) — round_indeterminate if the rounding style is indeterminable

    • (1.2) — round_toward_zero if the rounding style is toward zero

    • (1.3) — round_to_nearest if the rounding style is to the nearest representable value; if there are two equally near such values, the one with an even least significant digit is chosen

    • (1.4) — round_toward_infinity if the rounding style is toward infinity

    • (1.5) — round_toward_neg_infinity if the rounding style is toward negative infinity

    • (1.?) — round_to_nearest_from_zero if the rounding style is to the nearest representable value; if there are two equally near such values, the one with greater magnitude is chosen