Re: Here's my rounding
| From: | Tedd Sperling | Date: | Sat, 29 Sep 2012 16:15:07 +0000 |
| Subject: | Re: Here's my rounding | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-319300@lists.php.net to get a copy of this message | ||
On Sep 28, 2012, at 9:27 AM, Jim Giner <jim.giner@albanyhandball.com> wrote:
> On 9/28/2012 2:11 AM, Simon J Welsh wrote:
>> On 28/09/2012, at 6:08 PM, Chris Payne <oxygenet32@gmail.com> wrote:
>>
>> I would use something similar to $rounded_number = ceil($test2/1000)*1000;
>> ---
>> Simon Welsh
>> Admin of http://simon.geek.nz/
>>
> From my days as a math major, rounding doesn't always go up - it goes to the nearest level
> that you have indicated. As Simon shows you, you want to ceil to always go up, and floor to always
> go down. Neat function names actually... :)
A more accurate rounding is HALF-EVEN -- first Google search produces:
http://www.crazysquirrel.com/computing/java/basics/rounding.jspx
I did this with php several years ago, namely:
http://www.webbytedd.com/bbb/rounding/
I leave it to the community to develop the code.
Cheers,
tedd
_____________________
tedd@sperling.com
http://sperling.com