From:             bb at codepoet dot de
Operating system: Debian, Ubuntu, OSX
PHP version:      5.4.12
Package:          Variables related
Bug Type:         Bug
Bug description:Incorrect conversion between float and int

Description:
------------
If I multiply 19.99 with 100 and cast it to int, I expect a value of 1999,
but I 
get 1998. I verified this on 5 different php 5.4 installations on Mac OSX
10.8.2, 
Debian and Ubuntu.

Test script:
---------------
<?php
var_dump('TEST #1');
var_dump($x = floatval(19.99 * 100));
var_dump($x = intval($x));

var_dump('TEST #2');
var_dump($x = floatval(1999));
var_dump($x = intval($x));


Expected result:
----------------
string(7) "TEST #1"
double(1999)
int(1999)



Actual result:
--------------
string(7) "TEST #2"
double(1999)
int(1998)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=64415&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64415&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64415&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=64415&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=64415&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=64415&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=64415&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=64415&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=64415&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=64415&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=64415&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=64415&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=64415&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=64415&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64415&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=64415&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=64415&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=64415&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64415&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=64415&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64415&r=mysqlcfg

Reply via email to