Re: improve description of %a in printf(3)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 13 Nov 2024 at 11:38, Alejandro Colomar <alx@xxxxxxxxxx> wrote:
>
> Hi Ken,
>
> On Wed, Nov 13, 2024 at 02:11:52AM GMT, Ken Pizzini 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 (6.9.1) document what base is used for the "p±d" part of
> > the format.  Furthermore, the description refers to a "decimal point",
> > even though it would be better referred to as the "radix point",
> > as the number in question is not a decimal representation.
> >
> > 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; 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 and reading carefully could I determine
> > that the exponent in p-notation must always be taken from a base of 2.
> >
> > A patch with one suggested wording is attached. The entry for "a, A" in
> >    https://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html
>
> The latest standard is POSIX.1-2024.  Please link to it.
>
> <https://pubs.opengroup.org/onlinepubs/9799919799/functions/printf.html>
>
> > gives an even better rewording, though I suspect there would be
> > copyright issues in simply copying its text.
> >
> >               --Ken Pizzini
>
>
> The patch is missing the metadata that will make it be accepted by
> git-am(1).  Would you mind formatting the patch with
> git-format-patch(1)?
>
> See:
> <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING.d/patches/patches>
> <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING.d/patches/description>
> <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING.d/patches/subject>
>
> > --- printf.3~ 2024-11-13 01:07:23.023847047 -0800
> > +++ printf.3  2024-11-13 01:55:48.368341811 -0800
> > @@ -757,15 +757,18 @@
> >  the letters ABCDEF, and the exponent separator
> >  .B P
> >  is used.
> > -There is one hexadecimal digit before the decimal point,
> > +There is one hexadecimal digit before the radix point,
> >  and the number of digits after it is equal to the precision.
> >  The default precision suffices for an exact representation of the value
> >  if an exact representation in base 2 exists
> >  and otherwise is sufficiently large to distinguish values of type
> >  .IR double .
> > -The digit before the decimal point is unspecified for nonnormalized
> > +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
> > +The exponent
> > +.IR d ,

If there's a comma after d then shouldn't there be one before it too?

So either "The exponent, d, is ..." or just "The exponent d is ..."

But not "The exponent d, is ..."

> > +which is the appropriate exponent of 2 expressed as a decimal integer,
>
> I would remove the 'which', and s/,/;/
>
> > +always contains at least one
>
> And prepend an 'it' here.
>
> Other than that, it LGTM.  Thanks!
>
> Have a lovely day!
> Alex
>
> >  digit; if the value is zero, the exponent is 0.
> >  .TP
> >  .B c
>
>
> --
> <https://www.alejandro-colomar.es/>






[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux