Edit report at https://bugs.php.net/bug.php?id=62385&edit=1

 ID:                 62385
 User updated by:    iam4webwork at hotmail dot com
 Reported by:        iam4webwork at hotmail dot com
 Summary:            intval gives wrong result with float value
 Status:             Open
 Type:               Bug
 Package:            Math related
 PHP Version:        5.4.4
 Block user comment: N
 Private report:     N

 New Comment:

It only works correctly if you round the float value and then pass it to intval.


Previous Comments:
------------------------------------------------------------------------
[2012-06-21 23:41:56] iam4webwork at hotmail dot com

Description:
------------
A float value of 19.99 * 100 when passed to intval becomes 1998 unless embedded 
in 
a string.


Test script:
---------------
$amount = 19.99 * 100;
$test2 = intVal($amount);
$test3 = intVal("$amount");

echo $test2 . "<br />\n";
echo $test3 . "<br />\n";


Expected result:
----------------
1999
1999

Actual result:
--------------
1998
1999


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62385&edit=1

Reply via email to