Rounding numbers with respect to percentages
| From: | Herhuth, Ron | Date: | Mon, 28 Apr 2003 17:52:40 +0000 |
| Subject: | Rounding numbers with respect to percentages | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-19690@lists.php.net to get a copy of this message | ||
I am trying to dynamically calculate percentages and return the results
rounded off to the first decimal place. I tried using the
"round($num,1) " -- but the results don't always add up to 100%
"intval($num)" -- doesn't account for percentages that are less than 1
"floatval($num) -- doesn't allow me to round off to a specificed decimal
place, which in return gets me back to the same problem as "round"
How can I round off to the first decimal place making sure they add up to
100%?
Thanks,
Ron