Bug #51522 [Opn->Bgs]: function floor
| From: | pajoye@php.net | Date: | Fri, 09 Apr 2010 22:27:34 +0000 |
| Subject: | Bug #51522 [Opn->Bgs]: function floor | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-149461@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51522&edit=1
ID: 51522
Updated by: pajoye@php.net
Reported by: adrianoepn at hotmail dot com
Summary: function floor
-Status: Open
+Status: Bogus
Type: Bug
Package: *General Issues
Operating System: windows
PHP Version: 5.2.13
New Comment:
Floating point values have a limited precision. Hence a value might
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly
printing it without any mathematical operations.
If you would like to know more about "floats" and what IEEE
754 is, read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2010-04-10 00:19:18] adrianoepn at hotmail dot com
Description:
------------
example:
$value=30.40;
$comision=5;
$val_comision=($value*(1/(1-($comision/100)))-$value);
$suma=$val_comision + $value;
$value_acreditado=floor($suma);
$value_acreditado=31 // wrong result
but the correct answere is 32
Test script:
---------------
example:
$value=30.40;
$comision=5;
$val_comision=($value*(1/(1-($comision/100)))-$value);
$suma=$val_comision + $value;
$value_acreditado=floor($suma);
$value_acreditado=31 // wrong result
but the correct answere is 32
Expected result:
----------------
correct answere is 32
Actual result:
--------------
$value_acreditado=31
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51522&edit=1