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: -
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:
Status: Open Package: MySQLi related
PHP Version: 5.4.34 OS: FreeBSD 10.0, FreeBSD 9.1
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Thu Nov 15 17:01:26 2018 UTC