[resolved] Rounding Numbers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ibanez270dx
Forum Commoner
Posts: 74
Joined: Thu Jul 27, 2006 12:06 pm
Location: Everywhere, California

[resolved] Rounding Numbers

Post by ibanez270dx »

Hi,
Little quick question, I'm kinda pressed for time... My script has a section where it calculates an uptime percentage:

Code: Select all

$total_uptime_hrs = ($totaltime-$total_dwntime_hrs);
$uptime_percent = ($total_uptime_hrs*100);
$total_uptime_percent = ($uptime_percent/$totaltime);
When I output it, its a really long decimal. How can I round it to... lets say, 2 decimal places?

Thanks,
- Jeff
Last edited by ibanez270dx on Fri Jul 28, 2006 12:29 pm, edited 2 times in total.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Code: Select all

round()
LOL RTFM :lol:
ibanez270dx
Forum Commoner
Posts: 74
Joined: Thu Jul 27, 2006 12:06 pm
Location: Everywhere, California

Post by ibanez270dx »

hahaha! Well, I gotta start someplace...
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

No problem it was just sorta funny...
Post Reply