Edit report at http://bugs.php.net/bug.php?id=51522&edit=1
ID: 51522 Updated by: ras...@php.net Reported by: adrianoepn at hotmail dot com Summary: function floor Status: Bogus Type: Bug Package: *General Issues Operating System: windows PHP Version: 5.2.13 New Comment: And to fix your code, use: $suma=$val_comision + $value; $value_acreditado=floor(round($suma,2)); Previous Comments: ------------------------------------------------------------------------ [2010-04-10 00:27:34] paj...@php.net 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. ------------------------------------------------------------------------ [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