On Sun, Jan 30, 2011 at 10:39 PM, Adam Richardson <simples...@gmail.com>wrote:

## Advertising

> On Sun, Jan 30, 2011 at 8:44 PM, Marc Trudel <mtru...@wizcorp.jp> wrote:
>
>> Just out of curiosity, wouldnt it be better to use floor($n) instead of
>> round($n-0.5)?
>>
>
> Hi Marc,
>
> I don't think so, although I could have missed something (I just quick
> cranked out the example.) The definition I linked to involves rounding (2.5
> would round to 3, and 2.4 would round to 2), so I just included the rounding
> in the equation. Let me know if you see something I botched.
>
> Thanks,
>
> Adam
>
> --
> Nephtali: A simple, flexible, fast, and security-focused PHP framework
> http://nephtaliproject.com
>
Hi again Marc,
One other note. Maybe you were suggesting that the equation should have
been reduced to floor($n) instead round($n - .5).
I purposely tried to stay true to the equation/algorithm provided in the
link so it would be easy for the OP to see exactly where I got the equation
from and how I mapped it to PHP code (although I did have to adjust the
equation for zero indexes used in arrays.)
That all said, if you wanted to reduce the equation to floor($n) to produce
a more succinct representation, then you could certainly make that change
and it would produce the same result.
Thanks,
Adam
--
Nephtali: A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com