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

338. is whitespace allowed between `-' and a digit?

Section: 28.3.4 [locale.categories] Status: CD1 Submitter: Martin Sebor Opened: 2001-09-17 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [locale.categories].

View all issues with CD1 status.

Discussion:

From Stage 2 processing in 28.3.4.3.2.3 [facet.num.get.virtuals], p8 and 9 (the original text or the text corrected by the proposed resolution of issue 221(i)) it seems clear that no whitespace is allowed within a number, but 28.3.4.4.1 [locale.numpunct], p2, which gives the format for integer and floating point values, says that whitespace is optional between a plusminus and a sign.

The text needs to be clarified to either consistently allow or disallow whitespace between a plusminus and a sign. It might be worthwhile to consider the fact that the C library stdio facility does not permit whitespace embedded in numbers and neither does the C or C++ core language (the syntax of integer-literals is given in 5.13.2 [lex.icon], that of floating-point-literals in 5.13.4 [lex.fcon] of the C++ standard).

Proposed resolution:

Change the first part of 28.3.4.4.1 [locale.numpunct] paragraph 2 from:

The syntax for number formats is as follows, where digit represents the radix set specified by the fmtflags argument value, whitespace is as determined by the facet ctype<charT> (22.2.1.1), and thousands-sep and decimal-point are the results of corresponding numpunct<charT> members. Integer values have the format:

  integer   ::= [sign] units
  sign      ::= plusminus [whitespace]
  plusminus ::= '+' | '-'
  units     ::= digits [thousands-sep units]
  digits    ::= digit [digits]

to:

The syntax for number formats is as follows, where digit represents the radix set specified by the fmtflags argument value, and thousands-sep and decimal-point are the results of corresponding numpunct<charT> members. Integer values have the format:

  integer   ::= [sign] units
  sign      ::= plusminus
  plusminus ::= '+' | '-'
  units     ::= digits [thousands-sep units]
  digits    ::= digit [digits]

Rationale:

It's not clear whether the format described in 28.3.4.4.1 [locale.numpunct] paragraph 2 has any normative weight: nothing in the standard says how, or whether, it's used. However, there's no reason for it to differ gratuitously from the very specific description of numeric processing in 28.3.4.3.2.3 [facet.num.get.virtuals]. The proposed resolution removes all mention of "whitespace" from that format.