NYCPHP Meetup

NYPHP.org

[nycphp-talk] mathematical dilemma

Mitch Pirtle mitch.pirtle at gmail.com
Thu Sep 9 23:00:45 EDT 2004


Hi gang,

Winner of this one gets a beer at the next meet.

Say you have a collection of scores, 536 to be exact.  You need to
chop them up into deciles (first 10%, second 10%, etc.)

Now, take the score from the median, and add it to the last score in
the first decile.  Anything above that score gets 100 points.  Simple
enough, right?

But what if these scores include positive AND negative integers.  Then
'normal' math gives the wrong result...

So if the median is 2, and the last score in the first decile is -10,
I get -8.  That also is expected.

But if the median is 1, and the last score in the first decile is -7,
then I get -6.  I need -8, which is the problem...

What is the PHP way(TM) to get this behavior without doing a pile of
checks for whether the scores to compare are negative or not?

-- Mitch, alarmed that his math skills are so pitiful



More information about the talk mailing list