Bug #68657 [Asn->Csd]: Reading 4 byte floats with Mysqli and libmysqlclient has rounding errors
| From: | keyur@php.net | Date: | Wed, 07 Jan 2015 23:25:59 +0000 |
| Subject: | Bug #68657 [Asn->Csd]: Reading 4 byte floats with Mysqli and libmysqlclient has rounding errors | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189720@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68657&edit=1
ID: 68657
Updated by: keyur@php.net
Reported by: keyur@php.net
Summary: Reading 4 byte floats with Mysqli and libmysqlclient
has rounding errors
-Status: Assigned
+Status: Closed
Type: Bug
Package: MySQLi related
Operating System: Any
PHP Version: 5.5.20
Assigned To: keyur
Block user comment: N
Private report: N
New Comment:
The fix for this bug has been committed.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2014-12-26 21:55:07] keyur@php.net
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 this bug report at https://bugs.php.net/bug.php?id=68657&edit=1