Round() behaviour issue
| From: | Scott McDaid | Date: | Tue, 16 Dec 2003 11:13:25 +0000 |
| Subject: | Round() behaviour issue | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-172793@lists.php.net to get a copy of this message | ||
Hi there. I've been looking at the behaviour of the round functionality in
PHP. We're currently still using v4.2.3, (but the documentation seems to
suggest it's the same for versions after this).
Doing the following rounds always rounds *up* to the nearest whole number.
i.e.
0.5 => 1
1.5 => 2
2.5 => 3
3.5 => 4
In earlier PHP docs, it stated that halves would be rounded to the nearest
even number.
i.e.
3.5 => 4
4.5 => 4
When did this change. Or is this *actually* the case in a version of PHP
later than 4.2.3. I've had a look at the PHP changelog and the bug lists
and found nothing. :(
I know I can work around this by adding a fuzz factor, but I'd rather not.
I'm just confused as to why something so fundamental to math would change
across PHP versions.
Kind Regards
Scott
--
Scott McDaid
lightershade
t: +44 131 514 4000
d: +44 131 514 4009
--
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender. Any
offers or quotation of service are subject to formal specification.
Errors and omissions excepted. Please note that any views or opinions
presented in this email are solely those of the author and do not
necessarily represent those of edNET or lightershade ltd. Finally, the
recipient should check this email and any attachments for the presence of
viruses. edNET and lightershade ltd accepts no liability for any damage
caused by any virus transmitted by this email.
--
--
Virus scanned by edNET.