linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael Kerrisk (man-pages)" <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Christopher Hall <chall0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [patch] printf.3: correctly describe the meaning of a negative precision
Date: Wed, 04 Sep 2013 09:26:56 +0200	[thread overview]
Message-ID: <5226E0C0.7060005@gmail.com> (raw)
In-Reply-To: <CAB4OWr2UVqnv5hyrY5RkjWHYwMVGFFyByTy3uNZyrHVBdE8wxQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On 09/02/13 16:41, Christopher Hall wrote:
> The printf(3) manpage says that a negative precision is taken to be
> zero, whereas printf(3p) says that a negative precision is taken as if
> the precision were omitted.  glibc agrees with the latter (posix)
> specification.
> 
> Test code:
> 
>     printf("%f\n",42.0);      // "42.000000"
>     printf("%.*f\n",0,42.0);  // "42"
>     printf("%.*f\n",-1,42.0); // "42.000000"
> 
> This patch corrects the explanation to match what actually happens.

Thanks for the thorough and clear report, Chris. Patch applied.

Cheers,

Michael


> diff --git i/man3/printf.3 w/man3/printf.3
> index f5e96d3..2c86bf1 100644
> --- i/man3/printf.3
> +++ w/man3/printf.3
> @@ -409,8 +409,9 @@ Instead of a decimal digit string one may write
> "*" or "*mquot;
>  is given in the next argument, or in the m-th argument, respectively,
>  which must be of type
>  .IR int .
> -If the precision is given as just \(aq.\(aq, or the precision is negative,
> -the precision is taken to be zero.
> +If the precision is given as just \(aq.\(aq, the precision is taken to
> +be zero.  A negative precision is taken as if the precision were
> +omitted.
>  This gives the minimum number of digits to appear for
>  .BR d ,
>  .BR i ,
> 
> 
> --
> Chris Hall
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2013-09-04  7:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-02 14:41 [patch] printf.3: correctly describe the meaning of a negative precision Christopher Hall
     [not found] ` <CAB4OWr2UVqnv5hyrY5RkjWHYwMVGFFyByTy3uNZyrHVBdE8wxQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-09-04  7:26   ` Michael Kerrisk (man-pages) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5226E0C0.7060005@gmail.com \
    --to=mtk.manpages-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=chall0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).