Bug#658522: perldoc -f sprintf should mention half-way-point alternation
jidanni at jidanni.org
jidanni at jidanni.org
Fri Feb 3 16:56:04 UTC 2012
Package: perl-doc
Version: 5.14.2-7
Severity: wishlist
File: /usr/share/man/man1/perlfunc.1.gz
Maybe perlfunc sprintf and (linux man printf too!) should explicitly say
%f 0.5 rounds to 0 (and not 1), and so with -0.5. It seems never
mentioned there.
Wait! I mean:
$ perldoc -f sprintf
should mention something about the massive warning mentioned on
$ perldoc -q round
Found in /usr/share/perl/5.14/pod/perlfaq4.pod
Does Perl have a round() function? What about ceil() and floor()? Trig functions?
about half-way-point alternation.
Though
$ perldoc -f sprintf
might direct one to man printf(3), one will not find any clues about
half-way-point alternation there, at least on Debian.
printf(3) is quite long, and oddly seems to never mention it (please
somebody tell them to.)
So people reading
$ perldoc -f sprintf
just see
# Round number to 3 digits after decimal point
$rounded = sprintf("%.3f", $number);
Perl does its own "sprintf" formatting: it emulates the C
function sprintf(3), but doesn't use it except for
floating-point numbers, and even then only standard
modifiers are allowed. Non-standard extensions in your
local sprintf(3) are therefore unavailable from Perl.
still never aware of half-way-point alternation!
More information about the Perl-maintainers
mailing list