Skip to content

Commit fa86cec

Browse files
committed
New issue from Jan Schultke: ""round_to_nearest" rounding mode is unclear"
1 parent 370c780 commit fa86cec

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

xml/issue4474.xml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4474" status="New">
5+
<title>"`round_to_nearest`" rounding mode is unclear</title>
6+
<section><sref ref="[round.style]"/></section>
7+
<submitter>Jan Schultke</submitter>
8+
<date>13 Nov 2025</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<p>
13+
Consider the specification of `round_to_nearest` in <sref ref="[round.style]"/>:
14+
</p>
15+
<blockquote><p>
16+
`round_to_nearest` if the rounding style is to the nearest representable value
17+
</p></blockquote>
18+
<p>
19+
It is unclear how exact ties are rounded. For example, with this rounding, would a value
20+
that is equidistant to zero and <tt>numeric_limits&lt;float&gt;::min()</tt> be rounded
21+
towards zero or away from zero?
22+
<p/>
23+
In <sref ref="[numeric.limits.members]"/>, there exists a footnote for <tt>numeric_limits&lt;T&gt;::round_style</tt>:
24+
</p>
25+
<blockquote><p>
26+
185) Equivalent to `FLT_ROUNDS`. Required by ISO/IEC 10967-1:2012.
27+
</p></blockquote>
28+
<p>
29+
In C23 5.2.4.2.2 [Characteristics of floating types <tt>&lt;float.h&gt;</tt>], it is specified
30+
that a value of `1` for `FLT_ROUNDS` (which equals `round_to_nearest`) means
31+
</p>
32+
<blockquote><p>
33+
to nearest, ties to even
34+
</p></blockquote>
35+
<p>
36+
This is also the default ISO/IEC 60559 rounding mode, and chosen by standard libraries such as
37+
libstdc++ for `numeric_limits` under that assumption. Do note that C23 no longer references
38+
ISO/IEC 10967 in any normative wording, so presumably, matching `FLT_ROUNDS` values means to match
39+
the value that exists in C23, including its meaning.
40+
</p>
41+
</discussion>
42+
43+
<resolution>
44+
<p>
45+
This wording is relative to <paper num="N5014"/>.
46+
</p>
47+
48+
<ol>
49+
<li><p>Modify <sref ref="[round.style]"/> as indicated:</p>
50+
51+
<blockquote>
52+
<p>
53+
-1- The rounding mode for floating-point arithmetic is characterized by the values:
54+
</p>
55+
<ul style="list-style-type: none">
56+
<li>(1.1) &mdash;
57+
`round_indeterminate` if the rounding style is indeterminable
58+
</li>
59+
<li>(1.2) &mdash;
60+
`round_toward_zero` if the rounding style is toward zero
61+
</li>
62+
<li>(1.3) &mdash;
63+
`round_to_nearest` if the rounding style is to the nearest representable value<ins>; if there are
64+
two equally near such values, the one with an even least significant digit is chosen</ins>
65+
</li>
66+
<li>(1.4) &mdash;
67+
`round_toward_infinity` if the rounding style is toward infinity
68+
</li>
69+
<li>(1.5) &mdash;
70+
`round_toward_neg_infinity` if the rounding style is toward negative infinity
71+
</li>
72+
</ul>
73+
74+
</blockquote>
75+
</li>
76+
</ol>
77+
</resolution>
78+
79+
</issue>

0 commit comments

Comments
 (0)