in reply to Re^5: help with sprintf
in thread help with sprintf

yeah thats why i updated my post... even then, the numbers after 6 decimal places dont show.

Replies are listed 'Best First'.
Re^7: help with sprintf
by psini (Deacon) on Jun 26, 2008 at 19:10 UTC

    Well, this works for me.

    use strict; use warnings; my $base=2; my $power=-12; my $number = $base * (10**$power); my $p = abs($power); my $string=sprintf("%.${p}f", $number); print $string;

    Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

      You can also supply the field width as one of the args that you put after the format string, by putting "*" in the format where that numeric should go:
      my $string = sprintf( "%.*f", $p, $number );
      thx alot!