My goal is to input the amount of Bytes used by a user as $inputbox and
calculate how many kbs,megs,gigs along with $cost for the price per meg.

<?

$inputbox = "414478244";

// PROCESS DATA
$kbs = $inputbox/1024;
 $megs = $kbs/1024;
 $gigs = $megs/1024;

// CALC COST OF MEGS
cost = $megs * 0.05;

// OUT PUT DATA.
echo"<b>$inputbox bytes = </b><br>$kbs kb.<br>$megs meg @ $0.05c per Meg =
\$$cost<br>$gigs gig.<br><br>";

?>

This is what I get outputted.

414478244 bytes =
404763.910156 kb.
395.277256012 meg @ $0.05c per Meg = $19.7638628006
0.386012945324 gig.

Questions?
1. Should I be dividing by 1024 or 1000? This was passed to me by word of
mouth ...
2. Any way of rounding to 2 or 3 digests after the decimal point.
3. to remove any , from the inputted string.

/ Josh



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to