php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68264 Mysqli rounding bug in 4-byte float
Submitted: 2014-10-19 08:36 UTC Modified: 2020-10-29 10:00 UTC
Votes:22
Avg. Score:4.6 ± 1.0
Reproduced:18 of 20 (90.0%)
Same Version:16 (88.9%)
Same OS:16 (88.9%)
From: nikita at paymentwall dot com Assigned: nikic (profile)
Status: Closed Package: MySQLi related
PHP Version: 5.4.34 OS: FreeBSD 10.0, FreeBSD 9.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nikita at paymentwall dot com
New email:
PHP Version: OS:

 

 [2014-10-19 08:36 UTC] nikita at paymentwall dot com
Description:
------------
Related bug: https://bugs.php.net/bug.php?id=67839

There is an issue which occurs in the "else" condition in mysqlnd_ps_codec.c on line 224 https://github.com/php/php-src/commit/c044164a96553668cc6c4ae1eb32f18219308851#diff-244e2eb2c3973758baa5d722dc42e7c0

------------
PHP version: 5.4.34
OS: FreeBSD 10.0, FreeBSD 9.1
Compiled with clang, not GCC

Test script:
---------------
CREATE TABLE test_php_bug(id INT PRIMARY KEY, fp4 FLOAT(8,2), fp8 DOUBLE) ENGINE = InnoDB;
INSERT INTO test_php_bug(id, fp4, fp8) VALUES (1, 38.50, 38.50);

if (!($stmt = mysqli_prepare($link, "SELECT id, fp4, fp8 FROM test_php_bug WHERE id=1"))) {
       die();                                                                    
}
if (!mysqli_stmt_execute($stmt)) {
       die();
}
if (!($result = mysqli_stmt_get_result($stmt))) {
       die();
}
$data = mysqli_fetch_assoc($result);
print $data['id'] . ": " . $data['fp4'] . ": " . $data['fp8'] . "\n";

Expected result:
----------------
1: 38.5: 38.5

Actual result:
--------------
1: 38: 38.5

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-10-29 10:00 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2020-10-29 10:00 UTC] nikic@php.net
I believe the issue here was the use of a locale with a decimal separator other than ".". That issue was fixed in https://github.com/php/php-src/commit/d1cd489a53c697898c2da5101c775bd6259f4be0. If that wasn't the cause and this issue still exists, please tell me.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 16:01:35 2025 UTC