Title
std::format: # (alternate form) for NaN and inf
Status
c++20
Section
[format.string.std]
Submitter
Richard Smith

Created on 2019-08-05.00:00:00 last changed 45 months ago

Messages

Date: 2020-02-13.12:32:11

Proposed resolution:

This wording is relative to N4830.

  1. Modify [format.string.std] as indicated:

    -6- […] For floating-point types, the alternate form causes the result of the conversion of finite values to always contain a decimal-point character, even if no digits follow it. Normally, a decimal-point character appears in the result of these conversions only if a digit follows it. In addition, for g and G conversions, trailing zeros are not removed from the result.

Date: 2020-02-13.12:32:11

[ 2020-02 Status to Immediate on Thursday morning in Prague. ]

Date: 2019-08-05.00:00:00

We have:

"For floating-point numbers, the alternate form causes the result of the conversion to always contain a decimal-point character, even if no digits follow it."

So does that mean that infinity is formatted as "inf." and NaN as "nan."? (Or something like that? Where exactly do we add the decimal point in this case?) Or does this affect infinity but not NaN (because we can handwave that a NaN value is not a "floating-point number")?

I suspect that this should only cover finite floating-point numbers.

Victor Zverovich:

Right. So infinity and NaN should be still formatted as "inf" and "nan" without a decimal point.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: immediate -> wp
2020-02-13 12:32:11adminsetmessages: + msg11059
2020-02-13 12:32:11adminsetstatus: new -> immediate
2019-08-06 17:14:41adminsetmessages: + msg10548
2019-08-05 00:00:00admincreate