Стандарт языка Си С99 TC (1113411), страница 65
Текст из файла (страница 65)
If thespace and + flags both appear, the space flag is ignored.#The result is converted to an ‘‘alternative form’’. For o conversion, it increasesthe precision, if and only if necessary, to force the first digit of the result to be azero (if the value and precision are both 0, a single 0 is printed). For x (or X)conversion, a nonzero result has 0x (or 0X) prefixed to it.
For a, A, e, E, f, F, g,281) Note that 0 is taken as a flag, not as the beginning of a field width.282) The results of all floating conversions of a negative zero, and of negative values that round to zero,include a minus sign.350Library§7.24.2.1WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3and G conversions, the result of converting a floating-point number alwayscontains a decimal-point wide character, even if no digits follow it.
(Normally, adecimal-point wide character appears in the result of these conversions only if adigit follows it.) For g and G conversions, trailing zeros are not removed from theresult. For other conversions, the behavior is undefined.07For d, i, o, u, x, X, a, A, e, E, f, F, g, and G conversions, leading zeros(following any indication of sign or base) are used to pad to the field width ratherthan performing space padding, except when converting an infinity or NaN. If the0 and - flags both appear, the 0 flag is ignored.
For d, i, o, u, x, and Xconversions, if a precision is specified, the 0 flag is ignored. For otherconversions, the behavior is undefined.The length modifiers and their meanings are:hhSpecifies that a following d, i, o, u, x, or X conversion specifier applies to asigned char or unsigned char argument (the argument will havebeen promoted according to the integer promotions, but its value shall beconverted to signed char or unsigned char before printing); or thata following n conversion specifier applies to a pointer to a signed charargument.hSpecifies that a following d, i, o, u, x, or X conversion specifier applies to ashort int or unsigned short int argument (the argument willhave been promoted according to the integer promotions, but its value shallbe converted to short int or unsigned short int before printing);or that a following n conversion specifier applies to a pointer to a shortint argument.l (ell)Specifies that a following d, i, o, u, x, or X conversion specifier applies to along int or unsigned long int argument; that a following nconversion specifier applies to a pointer to a long int argument; that afollowing c conversion specifier applies to a wint_t argument; that afollowing s conversion specifier applies to a pointer to a wchar_targument; or has no effect on a following a, A, e, E, f, F, g, or G conversionspecifier.ll (ell-ell) Specifies that a following d, i, o, u, x, or X conversion specifier applies to along long int or unsigned long long int argument; or that afollowing n conversion specifier applies to a pointer to a long long intargument.j§7.24.2.1Specifies that a following d, i, o, u, x, or X conversion specifier applies toan intmax_t or uintmax_t argument; or that a following n conversionspecifier applies to a pointer to an intmax_t argument.Library351ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256zSpecifies that a following d, i, o, u, x, or X conversion specifier applies to asize_t or the corresponding signed integer type argument; or that afollowing n conversion specifier applies to a pointer to a signed integer typecorresponding to size_t argument.tSpecifies that a following d, i, o, u, x, or X conversion specifier applies to aptrdiff_t or the corresponding unsigned integer type argument; or that afollowing n conversion specifier applies to a pointer to a ptrdiff_targument.LSpecifies that a following a, A, e, E, f, F, g, or G conversion specifierapplies to a long double argument.If a length modifier appears with any conversion specifier other than as specified above,the behavior is undefined.8The conversion specifiers and their meanings are:d,iThe int argument is converted to signed decimal in the style [−]dddd.
Theprecision specifies the minimum number of digits to appear; if the valuebeing converted can be represented in fewer digits, it is expanded withleading zeros. The default precision is 1. The result of converting a zerovalue with a precision of zero is no wide characters.o,u,x,X The unsigned int argument is converted to unsigned octal (o), unsigneddecimal (u), or unsigned hexadecimal notation (x or X) in the style dddd; theletters abcdef are used for x conversion and the letters ABCDEF for Xconversion. The precision specifies the minimum number of digits to appear;if the value being converted can be represented in fewer digits, it is expandedwith leading zeros.
The default precision is 1. The result of converting azero value with a precision of zero is no wide characters.f,FA double argument representing a floating-point number is converted todecimal notation in the style [−]ddd.ddd, where the number of digits afterthe decimal-point wide character is equal to the precision specification. If theprecision is missing, it is taken as 6; if the precision is zero and the # flag isnot specified, no decimal-point wide character appears.
If a decimal-pointwide character appears, at least one digit appears before it. The value isrounded to the appropriate number of digits.A double argument representing an infinity is converted in one of the styles[-]inf or [-]infinity — which style is implementation-defined. Adouble argument representing a NaN is converted in one of the styles[-]nan or [-]nan(n-wchar-sequence) — which style, and the meaning ofany n-wchar-sequence, is implementation-defined. The F conversionspecifier produces INF, INFINITY, or NAN instead of inf, infinity, or352Library§7.24.2.1WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3nan, respectively.283)e,EA double argument representing a floating-point number is converted in thestyle [−]d.ddd e±dd, where there is one digit (which is nonzero if theargument is nonzero) before the decimal-point wide character and the numberof digits after it is equal to the precision; if the precision is missing, it is takenas 6; if the precision is zero and the # flag is not specified, no decimal-pointwide character appears.
The value is rounded to the appropriate number ofdigits. The E conversion specifier produces a number with E instead of eintroducing the exponent. The exponent always contains at least two digits,and only as many more digits as necessary to represent the exponent. If thevalue is zero, the exponent is zero.A double argument representing an infinity or NaN is converted in the styleof an f or F conversion specifier.g,GA double argument representing a floating-point number is converted instyle f or e (or in style F or E in the case of a G conversion specifier),depending on the value converted and the precision. Let P equal theprecision if nonzero, 6 if the precision is omitted, or 1 if the precision is zero.Then, if a conversion with style E would have an exponent of X :— if P > X ≥ −4, the conversion is with style f (or F) and precisionP − (X + 1).— otherwise, the conversion is with style e (or E) and precision P − 1.Finally, unless the # flag is used, any trailing zeros are removed from thefractional portion of the result and the decimal-point wide character isremoved if there is no fractional portion remaining.A double argument representing an infinity or NaN is converted in the styleof an f or F conversion specifier.a,AA double argument representing a floating-point number is converted in thestyle [−]0xh.hhhh p±d, where there is one hexadecimal digit (which isnonzero if the argument is a normalized floating-point number and isotherwise unspecified) before the decimal-point wide character284) and thenumber of hexadecimal digits after it is equal to the precision; if the precisionis missing and FLT_RADIX is a power of 2, then the precision is sufficient283) When applied to infinite and NaN values, the -, +, and space flag wide characters have their usualmeaning; the # and 0 flag wide characters have no effect.284) Binary implementations can choose the hexadecimal digit to the left of the decimal-point widecharacter so that subsequent digits align to nibble (4-bit) boundaries.§7.24.2.1Library353ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256for an exact representation of the value; if the precision is missing andFLT_RADIX is not a power of 2, then the precision is sufficient todistinguish285) values of type double, except that trailing zeros may beomitted; if the precision is zero and the # flag is not specified, no decimalpoint wide character appears.
The letters abcdef are used for a conversionand the letters ABCDEF for A conversion. The A conversion specifierproduces a number with X and P instead of x and p. The exponent alwayscontains at least one digit, and only as many more digits as necessary torepresent the decimal exponent of 2. If the value is zero, the exponent iszero.A double argument representing an infinity or NaN is converted in the styleof an f or F conversion specifier.cIf no l length modifier is present, the int argument is converted to a widecharacter as if by calling btowc and the resulting wide character is written.If an l length modifier is present, the wint_t argument is converted towchar_t and written.sIf no l length modifier is present, the argument shall be a pointer to the initialelement of a character array containing a multibyte character sequencebeginning in the initial shift state.