Skip to content

Commit 5d093bf

Browse files
committed
Update paper
1 parent dd9ab28 commit 5d093bf

File tree

2 files changed

+84
-129
lines changed

2 files changed

+84
-129
lines changed

papers/p3505.bs

Lines changed: 38 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<pre class='metadata'>
22
Title: Fix the default floating-point representation in std::format
33
Shortname: P3505
4-
Revision: 2
4+
Revision: 3
55
Audience: LEWG
66
Status: P
77
Group: WG21
88
URL:
99
Editor: Victor Zverovich, victor.zverovich@gmail.com
1010
Editor: Junekey Jeon, j6jeon@ucsd.edu
1111
No abstract: true
12-
Date: 2025-10-07
12+
Date: 2025-10-08
1313
Markup Shorthands: markdown yes
1414
</pre>
1515

@@ -30,6 +30,12 @@ other mainstream programming languages that have similar facilities. This paper
3030
proposes fixing this issue, bringing the floating-point formatting on par with
3131
other languages and in line with the original design intent.
3232

33+
# Changes since R2 # {#changes2}
34+
35+
- Add LEWG poll results.
36+
- Clarify that the paper fixes `std::to_chars` in addition to `std::format`.
37+
- Remove option 1 from the wording, leaving only LEWG-approved changes.
38+
3339
# Changes since R1 # {#changes1}
3440

3541
- Added an option to fix `std::to_chars` per feedback from the author of
@@ -46,6 +52,34 @@ other languages and in line with the original design intent.
4652
- Use the same number in Python and C++ to illustrate that the former
4753
satisifies shortness requirements and the latter doesn't.
4854

55+
Polls {#polls}
56+
=====
57+
58+
LEWG poll results for R2:
59+
60+
**POLL**: Change the behavior for printing floating point values using
61+
`to_chars()` as proposed in P3505R2 (option 2)
62+
63+
```text
64+
SF F N A SA
65+
9 4 0 0 0
66+
```
67+
68+
Outcome: Unanimous consensus in favour.
69+
70+
71+
**POLL**: Bump FTMs `__cpp_lib_to_chars`, `__cpp_lib_constexpr_charconv` and
72+
forward the corrected paper (P3505R2) to LWG for C++29 (with a recommendation
73+
to make it a DR for C++17, C++20, C++23, C++26), to be confirmed via electronic
74+
poll.
75+
76+
```text
77+
SF F N A SA
78+
9 4 0 0 0
79+
```
80+
81+
Outcome: Unanimous consensus in favour.
82+
4983
Problem {#problem}
5084
=======
5185

@@ -381,7 +415,8 @@ Proposal {#proposal}
381415
========
382416

383417
The current paper proposes fixing the default floating-point representation in
384-
`std::format` to use exponent range, fixing the issues described above.
418+
`std::format` (and `std::to_char`) to use exponent range, fixing the issues
419+
described above.
385420

386421
Consistent, easy to reason about output format:
387422

@@ -489,68 +524,6 @@ std::format("{:L}", 1200000.0)
489524
Wording {#wording}
490525
=======
491526

492-
Option 1: fix `std::format` {#option1}
493-
---------------------------
494-
495-
Modify [[format.string.std](https://eel.is/c++draft/format.string.std)]:
496-
497-
Table 105 — Meaning of type options for floating-point types
498-
[[tab:format.type.float](https://eel.is/c++draft/format.string.std)]
499-
500-
<table>
501-
<tr>
502-
<td>**Type**
503-
<td>**Meaning**
504-
</tr>
505-
<tr>
506-
<td>`a`
507-
<td>
508-
If *precision* is specified, equivalent to
509-
```
510-
to_chars(first, last, value, chars_format::hex, precision)
511-
```
512-
where `precision` is the specified formatting precision; equivalent to
513-
```
514-
to_chars(first, last, value, chars_format::hex)
515-
```
516-
otherwise.
517-
</tr>
518-
<tr>
519-
<td>...
520-
<td>...
521-
</tr>
522-
<tr>
523-
<td>`G`
524-
<td>The same as `g`, except that it uses `E` to indicate exponent.
525-
</tr>
526-
<tr>
527-
<td>none
528-
<td>
529-
<ins>Let <code>T</code> be <code>decltype(value)</code>.
530-
Let <code>fmt</code> be `chars_format::fixed` if the absolute value of
531-
<code>value</code> is in the range [<i>m</i>, <i>n</i>), where <i>m</i> is
532-
the nearest representable as <code>T</code> value of 10<sup>-4</sup> and
533-
<i>n</i> is the nearest representable as <code>T</code> value of
534-
<code>std::numeric_limits&lt;T&gt;::radix</code><!--
535-
--><sup><code>std::numeric_limits&lt;T&gt;::digits</code> + 1</sup> rounded
536-
down to the nearest power of 10, `chars_format::scientific` otherwise.
537-
</ins>
538-
539-
If *precision* is specified, equivalent to
540-
```
541-
to_chars(first, last, value, chars_format::general, precision)
542-
```
543-
where `precision` is the specified formatting precision; equivalent to
544-
<pre>
545-
to_chars(first, last, value<ins>, fmt</ins>)
546-
</pre>
547-
otherwise.
548-
</tr>
549-
</table>
550-
551-
Option 2: fix `std::to_chars` {#option2}
552-
-----------------------------
553-
554527
Update the value of the feature-testing macros `__cpp_lib_to_chars` and
555528
`__cpp_lib_constexpr_charconv` to the date of adoption in
556529
[[version.syn](https://eel.is/c++draft/version.syn)].

0 commit comments

Comments
 (0)