Bug 190341 - printf(3): Incorrect description of "L" and "ll" prefixes
Summary: printf(3): Incorrect description of "L" and "ll" prefixes
Status: RESOLVED CODE_FIX
Alias: None
Product: Documentation
Classification: Unclassified
Component: man-pages (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: documentation_man-pages@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-14 11:47 UTC by Nadav Har'El
Modified: 2017-01-25 20:44 UTC (History)
1 user (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Nadav Har'El 2016-12-14 11:47:44 UTC
The Posix printf(3) manual (http://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html) says that there is a difference between the "ll" and "L" prefixes: The former only works for integer types and formats, and the latter only for floating point (long long double).

Our printf(3) manual also starts with explaining exactly the same distinction, but then adds a line which contradicts itself - it says for LL that "This is a synonym for ll.", despite just having explained that there is a difference between them.

In fact, in glibc's printf(), LL and ll indeed seem to be synonyms, and both support either integers and floating point. The sample program:

    long double d = 123.456;
    printf("Lf: %Lf\n", d); 
    printf("llf %llf\n", d); 
    long long int i = 123456;
    printf("Ld: %Ld\n", i); 
    printf("lld: %lld\n", i); 

produces four lines of output:

    Lf: 123.456000
    llf 123.456000
    Ld: 123456
    lld: 123456

So our printf(3) manual should probably not have a separate "ll" and "L" sections - rather it should have a single "ll or L" section, about both integer and floating point types. It might be interesting to mention that for Posix compatibility, L should be used for the floating point types and ll for the integer types.
Comment 1 Michael Kerrisk 2017-01-25 20:44:24 UTC
Thanks for the report.

I removed the simple statement that 'll' is a synonym for 'L' and added the following text later in the page:

       As  a nonstandard extension, the GNU implementations treats ll and
       L as synonyms, so that one can, for example, write llg (as a  syn‐
       onym  for the standards-compliant Lg) and Ld (as a synonym for the
       standards compliant lld).  Such usage is nonportable.

I'll close this now.

Note You need to log in before you can comment on or make changes to this bug.