* [patch] printf.3: correctly describe the meaning of a negative precision
@ 2013-09-02 14:41 Christopher Hall
[not found] ` <CAB4OWr2UVqnv5hyrY5RkjWHYwMVGFFyByTy3uNZyrHVBdE8wxQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Christopher Hall @ 2013-09-02 14:41 UTC (permalink / raw)
To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA
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.
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch] printf.3: correctly describe the meaning of a negative precision
[not found] ` <CAB4OWr2UVqnv5hyrY5RkjWHYwMVGFFyByTy3uNZyrHVBdE8wxQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-09-04 7:26 ` Michael Kerrisk (man-pages)
0 siblings, 0 replies; 2+ messages in thread
From: Michael Kerrisk (man-pages) @ 2013-09-04 7:26 UTC (permalink / raw)
To: Christopher Hall
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w,
linux-man-u79uwXL29TY76Z2rM5mHXA
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-09-04 7:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).