Hi,
I try to do the rounding as follow, some of numbers is working but some are not.
Original value : 5299792.155 and it show 5.3 after the following statement, but what I want is show as 5300 round up to 1000's
$rounded = substr(round($value['SUM(sales)'], -3), 0, -3); if ($rounded == 0) { echo "0"; } else { echo $rounded; }
Any idea
Thanks!
Rounding number question? PLEASE HELP!
Moderator: General Moderators
-
mapperkids
- Forum Newbie
- Posts: 15
- Joined: Mon Feb 11, 2008 8:53 pm
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: Rounding number question? PLEASE HELP!
try number_format, I think it will do all of it for you.
-
mapperkids
- Forum Newbie
- Posts: 15
- Joined: Mon Feb 11, 2008 8:53 pm
Re: Rounding number question? PLEASE HELP!
thanks,jaoudestudios wrote:try number_format, I think it will do all of it for you.
but how can I turn the 553235 become 553 (show by 1000s) only using number_format?
Thanks!
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: Rounding number question? PLEASE HELP!
Not sure why you would do that as you loose information, but you can divide it by 1000
i.e. 553235 / 1000
i.e. 553235 / 1000
Re: Rounding number question? PLEASE HELP!
Divide by your denominator and then use floor(), ceil() or number_format().. or a combination thereof