On Fri, 15 Nov 2024 at 08:24, Ken Pizzini <ken@xxxxxxx> wrote: > > The description of the %a/%A specifiers in the printf(3) man page > could stand some improvement. In particular, it is not clear from the > current document what base is used for the "p±d" part of the format. > > It can be inferred from the nature of %a that the base should be > a power of two. and it can be further inferred from the nature of > hexadecimal floating-point literals in C (as specified by C99 and > later) that the base must exactly be the number two, but it would be > helpful for the printf(3) man page to state this explicitly. My first > expectation when reading the man page was that the exponent would be > taken in base 16; after experimentation my second thought is that it > is base FLT_RADIX (which is 2 on IEEE 754 floating-point systems, but > 16 on S/390). Only by going back to the standard [1] could I determine > that the exponent in p-notation must always be taken from a base of 2. > > [1] POSIX.1-2024 > <https://pubs.opengroup.org/onlinepubs/9799919799/functions/printf.html> > > Signed-off-by: Ken Pizzini <ken@xxxxxxx> > --- > man/man3/printf.3 | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/man/man3/printf.3 b/man/man3/printf.3 > index 7a96ec9c7..acabb3c3a 100644 > --- a/man/man3/printf.3 > +++ b/man/man3/printf.3 > @@ -767,8 +767,11 @@ .SS Conversion specifiers > .IR double . > The digit before the radix point is unspecified for nonnormalized > numbers, and nonzero but otherwise unspecified for normalized numbers. > -The exponent always contains at least one > -digit; if the value is zero, the exponent is 0. > +The exponent, > +.IR d , > +which is the appropriate exponent of 2 expressed as a decimal integer, > +always contains at least one digit; Alex's suggestion (which I agree with) was: > +is the appropriate exponent of 2 expressed as a decimal integer; > +it always contains at least one digit; Remove "which", change the comma to "; it" > +if the value is zero, the exponent is 0. > .TP > .B c > If no > -- > 2.47.0 >