[php-src] Issue #8510: PDO Sqlite is truncating float

From: Date: Sat, 07 May 2022 15:07:11 +0000
Subject: [php-src] Issue #8510: PDO Sqlite is truncating float
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241433@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8510 Author: mvorisek ### Description The following code: ```php <?php $pdo = new PDO('sqlite::memory:'); $pdo->exec('CREATE TABLE "types" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "float" DOUBLE PRECISION)'); $pdo->exec('insert into "types" ("float") values (10)'); $pdo->exec('update types set float = 8.202343767574732'); $stored = $pdo->query('select float from types limit 1')->fetchColumn(0); var_dump($stored); var_dump(bin2hex(pack('e', $stored))); $pdo->exec('update types set float = \'8.202343767574732\''); $stored = $pdo->query('select float from types limit 1')->fetchColumn(0); var_dump($stored); var_dump(bin2hex(pack('e', $stored))); ``` Resulted in output with truncated float numbers, but I expected this output instead: ```diff -string(16) "8.20234376757473" +string(16) "8.202343767574732" -string(16) "d790309a99672040" +string(16) "d890309a99672040" -string(16) "8.20234376757473" +string(16) "8.202343767574732" -string(16) "d790309a99672040" +string(16) "d890309a99672040" ``` demo: https://3v4l.org/5Qtf8 since PHP 8.1, a float Sqlite datatype is returned as a php float type and the result is correct ### PHP Version PHP 8.0 ### Operating System any

« previous php.bugs (#241433) next »