• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

Change 88.5454675463 to 88.55

Hi....
$var = 88.5454675463;
#How do I change it so that.....
$var = 88.55; #2 decimal places
regards
0
rickyr
Asked:
rickyr
  • 2
  • 2
1 Solution
 
ozoCommented:
$var = sprintf"%.2f",$var;
0
 
essuuCommented:
One easy way of doing this is:

$var=(int($var*100)/100);


0
 
rickyrAuthor Commented:
Hi.....
If $var = 85.568 then the 6 doesn't get rounded up to a 7.
But even if it did work, Ozo was here first, so he should get the points. (sorry).
Where are you ozo???????
regards
0
 
ozoCommented:
$var = sprintf"%.2f",$var;
#or
use POSIX;
$var = floor($var*100+0.5)/100;


see also:
perldoc -q round
0
 
rickyrAuthor Commented:
Thanks for the extra info, ozo.
cheers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now