Well, do you want to round or trim? The number you mention rounded to 2dp
would be 25.00. Trimmed to 2dp would be 24.99.

To round the number you could do this

$number = "24.999997";
$rounded = sprintf "%.2f",$number;
print $rounded;

To trim you could do

$number = "24.999997";
($rounded) = $number =~ /(\d*\.\d{2})/;
print $rounded;

John

-----Original Message-----
From: FLAHERTY, JIM-CONT [mailto:[EMAIL PROTECTED]]
Sent: 08 February 2002 14:48
To: Beginners (E-mail)
Subject: How do I get trim or rounding on a float number ?


$ aver = $total_hours/$total_jobs
 
 
some times comes up with   24.999997  . I would like to round or trim to
24.99 for example .  any Ideas  ??
 
 
thanks 
Jim F
 


--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



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

Reply via email to