Package: perl-doc
Version: 5.8.8-7
Severity: wishlist

Some key points of printf(3)'s

       g,G The double argument is converted in style f or e (or F or E
              for G conversions). The precision specifies the number
              of significant digits. If the precision is missing, 6
              digits are given; if the precision is zero, it is
              treated as 1. Style e is used if the exponent from its
              conversion is less than -4 or greater than or equal to
              the precision. Trailing zeros are removed from the
              fractional part of the result; a decimal point appears
              only if it is followed by at least one digit.

are not mentioned at all in perldoc -f sprintf, nor do the examples
there show cases like the below. As far as patches, perhaps just use
printf(3)'s.

This would cause some users to pass up %g, and end up posting:
-------------
Should the perl sprintf documentation be augmented? It says

  Arguments are usually formatted to be only as wide as required to
  display the given value.

But to get the versions on the right,

  6.250000 6.25
  12.500000 12.5
  18.750000 18.75
  25.000000 25
  31.250000 31.25

I had to do

  for ( 1 .. 5 ) {
      my $f = $_ * 6.25;
      my $s = $f;
      $f =~ s/\.?0+$//;
      printf "%f $s\n", $f;
  }


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to