Reading 4 byte floats with Mysqli and libmysqlclient has rounding errors
| Bug #68657 | Reading 4 byte floats with Mysqli and libmysqlclient has rounding errors | ||||
|---|---|---|---|---|---|
| Submitted: | 2014-12-26 21:55 UTC | Modified: | 2015-01-07 23:25 UTC | ||
| From: | keyur@php.net | Assigned: | keyur (profile) | ||
| Status: | Closed | Package: | MySQLi related | ||
| PHP Version: | 5.5.20 | OS: | Any | ||
| Private report: | No | CVE-ID: | None | ||
[2014-12-26 21:55 UTC] 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) }
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2014-12-26 21:56 UTC] keyur@php.net
-Assigned To: +Assigned To: keyur
[2015-01-07 23:25 UTC] keyur@php.net
-Status: Assigned +Status: Closed
[2015-01-07 23:25 UTC] keyur@php.net