On Thu, Nov 21, 2002 at 04:57:03PM -0200, [EMAIL PROTECTED] wrote:
> Hi,

Hi,

> How do i solve this
> Say i have an variable $number witch has the integer value of 16.526899874
> I wan to print it formatted like 16.52 (only 2 decimals)
> How do i do this with the basic print "$number"; command?
> Is there an "format string" like ##.##
> ?
> Thanks in advance

You want printf().

        my $number = 16.526899874;
        printf("%.2f\n", $number);

`perldoc -f sprintf` explains the formatting printf() and sprintf() use.

HTH,
-- 
Michael
[EMAIL PROTECTED]
http://www.jedimike.net/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to