Why not use the sprintf or printf function?

# Assigns 3.14 to the $decimal variable
my $decimal = 3.1415;
$decimal = sprintf('%.2f', $decimal);

# Prints 3.14
my $decimal = 3.1415;
printf('%.2f', $decimal);

# Prints 3.1
my $decimal = 3.1415;
printf('%.1f', $decimal);

You get the idea...

Best Regards,
JOSHUA D. HAYDEN

----- Original Message -----
From: "Octavian Rasnita" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 01, 2002 3:36 AM
Subject: 1 or 2 decimals


> Hi all,
>
> I have a number with a lot of decimals but I want to have it only with 1
or
> 2.
> I don't want 3.1415... etc, but only 3.1 or 3.14.
>
> Can you give me some hints what should I do?
>
> Thank you.
>
> Teddy,
> My dear email address is [EMAIL PROTECTED]
>
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>


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

Reply via email to