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

example: Input: (user selects)
2 e -10 (No. between 0-9) e (No. between 10 and -20)
I want the output to be 0.0000000002 instead of 2e-10 I hope this helps...

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

    If $power is negative, you should define another var equal to -$power.

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

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

        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."