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.
round_to_nearest" rounding mode is unclearSection: 17.3.4 [round.style] Status: New Submitter: Jan Schultke Opened: 2025-11-13 Last modified: 2025-11-15
Priority: Not Prioritized
View all issues with New status.
Discussion:
Consider the specification of round_to_nearest in 17.3.4 [round.style]:
round_to_nearestif the rounding style is to the nearest representable value
It is unclear how exact ties are rounded. For example, with this rounding, would a value
that is equidistant to zero and numeric_limits<float>::min() be rounded
towards zero or away from zero?
numeric_limits<T>::round_style:
185) Equivalent to
FLT_ROUNDS. Required by ISO/IEC 10967-1:2012.
In C23 5.2.4.2.2 [Characteristics of floating types <float.h>], it is specified
that a value of 1 for FLT_ROUNDS (which equals round_to_nearest) means
to nearest, ties to even
This is also the default ISO/IEC 60559 rounding mode, and chosen by standard libraries such as
libstdc++ for numeric_limits under that assumption. Do note that C23 no longer references
ISO/IEC 10967 in any normative wording, so presumably, matching FLT_ROUNDS values means to match
the value that exists in C23, including its meaning.
Proposed resolution:
This wording is relative to N5014.
Modify 17.3.4 [round.style] as indicated:
-1- The rounding mode for floating-point arithmetic is characterized by the values:
- (1.1) —
round_indeterminateif the rounding style is indeterminable- (1.2) —
round_toward_zeroif the rounding style is toward zero- (1.3) —
round_to_nearestif 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_infinityif the rounding style is toward infinity- (1.5) —
round_toward_neg_infinityif the rounding style is toward negative infinity