Shall we settle this argument once and for all?...

The answer is
$value = round($value, 2);

Which I found after a quick look in the manual.  Silly me expected the
original poster to have actually searched this far and found there WASN'T a
pre-written function.

Really irritates me that, and I'm sure we'll all agree on that! ;D

Ross

-----Original Message-----
From: Mike Flynn [mailto:[EMAIL PROTECTED]]
Sent: 09 April 2002 18:23
To: Svensson, B.A.T. (HKG)
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP-WIN] Rounding


At 05:49 PM 4/9/02 +0200, Svensson, B.A.T. (HKG) wrote:
>The number '2' I now have, was it - to be extreme - it '1,1' (a sealing
>function) or was it '2,9' (a floor function) before? You can never really
>tell...

If it was by the rule we've settled on below, then if you have 2, then the
number you previously had was >=1.5 and < 2.5. :)

>Which integer is "nearest" for 1,5? 1 or 2? To round a decimal
number is not
>as straight forward as it might appear in the first case.

1.5 is the only special case.

>In the bitter end this choice is up to the API writers own whim,
but in most
>case I guess (s)he ignore this case, and I would guess that most rounding
>function then perform a floor function in the case of ==5 (????).

As far as I know, .5 always gets rounded up, not down.  In school we were
taught, "Four to the floor, Five to the sky". :)

>Because of this I believe it a bit ambiguous to say "normal" since
it hardly
>can't exist a "normal" way to perform a rounding. Or??

I guess.  The dictionary defines normal, though, as "Conforming with,
adhering to, or constituting a norm, standard, pattern, level, or type;
typical".  So if there is a standard, typical, etc. way that rounding is
done, then you can certainly make a case that there is a normal kind of
rounding.  In ALL of my experiences, rounding has been defined as going to
the nearest integer, and rounding UP on .5.  And, like I said, all
programming languages I have encountered perform a standard rounding the
same way.  That's why we as societies settle on norms -- so we can
communicate without having to resort to academic analyses of every term we
use. :)  There's no need to feel the need to one-up everything I say. :)

>Secondly, because of this "phenomena" some programmers might
frequently find
>them self having to answers question from customer like:
>
>"Why does we miss $xxxx in this last summary report?".

Hehe.. brings to mind the movie "Office Space".

-Mike


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to