Bug #68657 [NEW]: Reading 4 byte floats with Mysqli and libmysqlclient has rounding errors
| From: | keyur@php.net | Date: | Fri, 26 Dec 2014 21:55:08 +0000 |
| Subject: | Bug #68657 [NEW]: Reading 4 byte floats with Mysqli and libmysqlclient has rounding errors | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-189221@lists.php.net to get a copy of this message | ||
From: keyur
Operating system: Any
PHP version: 5.5.20
Package: MySQLi related
Bug Type: Bug
Bug description:Reading 4 byte floats with Mysqli and libmysqlclient has rounding errors
Description:
------------
This is similar to the bug 67839.
The patch for that was only done to the mysqlnd driver and needs to be
reapplied to the libmysqlclient driver as well.
Test script:
---------------
On a MySQL DB, run the following queries:
CREATE TABLE test(id INT PRIMARY KEY, fp4 FLOAT, fp8 DOUBLE) ENGINE =
InnoDB;
INSERT INTO test(id, fp4, fp8) VALUES (1, 9.9999, 9.9999)
Now using mysqli, SELECT the one row out:
$id = null;
$fp4 = null;
$fp8 = null;
$stmt = mysqli_prepare($link, "SELECT * FROM test");
mysqli_stmt_bind_result($stmt, $id, $fp4, $fp8);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$test = array($id, $fp4, $fp8);
var_dump($test);
Expected result:
----------------
It should be:
array(3) {
[0]=>
int(1)
[1]=>
float(9.9999)
[2]=>
float(9.9999)
}
Actual result:
--------------
The output will be:
array(3) {
[0]=>
int(1)
[1]=>
float(9.9998998642)
[2]=>
float(9.9999)
}
--
Edit bug report at https://bugs.php.net/bug.php?id=68657&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68657&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68657&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68657&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68657&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68657&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68657&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68657&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68657&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68657&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68657&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68657&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68657&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68657&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68657&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68657&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68657&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68657&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68657&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68657&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68657&r=mysqlcfg