Submitter:Fred Tydeman
Submission Date: 2019-05-08
Document: WG14 N2380
Title:N2380: printf of NaN()
Reference Documents: N2301 N2320

Summary

There is no way for a user's application to know the maximum number of characters in the NaN(n-char-sequence) output by printf(); the standard imposes no upper limit.

Aside: This change does not address the issue of the user having no control over the style of the output of NaN versus NaN(n-char-sequence). I have not heard that users are asking for such a change to allow such control.

Technical Corrigendum:

Add to §7.21.1 <stdio.h>, paragraph 3 [macros],

_PRINTF_MAX_NAN_LEN

which expands to an integer constant expression (suitable for use in #if preprocessing directives) that is the maximum number of characters output for any [-]NAN(n-char-sequence) [footnote]. If an implementation has no support for NaNs, it shall be 0. _PRINTF_MAX_NAN_LEN shall be less than 32

[footnote]If the implementation only uses the [-]NAN style, then _PRINTF_MAX_NAN_LEN would have the value 4.