[PATCH v3] printf(3): improve description of %a format

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

 



[I've incorporated wording fixes from Alex.  Part 1/2 of the previous
patch set was accepted; this patch assumes that part 2/2 was not
applied (i.e, this submission is not incremental relative to the
earlier one).  I'm not sure if this is the preferred way of doing
things, but hopefully good enough?]


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..2129e26dc 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 ,
+is the appropriate exponent of 2 expressed as a decimal integer;
+it always contains at least one digit;
+if the value is zero, the exponent is 0.
 .TP
 .B c
 If no
-- 
2.47.0

Attachment: signature.asc
Description: PGP signature


[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