Bug #77192 [Opn->Nab]: Rounding of double precision column
Edit report at https://bugs.php.net/bug.php?id=77192&edit=1
ID: 77192
Updated by: cmb@php.net
Reported by: celiorod21 at gmail dot com
Summary: Rounding of double precision column
-Status: Open
+Status: Not a bug
Type: Bug
Package: PDO Firebird
Operating System: Irrelevant
PHP Version: 7.2.12
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This is to be expected, because DOUBLE PRECISION stores floating
point numbers and these are not precise by definition. USE
DECIMAL(15, 13) or something like that to get exact values.
Previous Comments:
------------------------------------------------------------------------
[2018-11-23 13:54:05] celiorod21 at gmail dot com
Description:
------------
I'm working with geolocation and storing latitude and longitude data in a DOUBLE PRECISION
field on firebird.
When searching for these records, the PDO is rounding the values, as well as returning them as a
string.
The insertion of the data is not done from PDO but by an external system and is correct.
Test script:
---------------
<?php
$conn = new PDO("firebird:dbname={$database}", "SYSDBA",
"masterkey");
$query = $conn->query('SELECT CAST(25.3639309364232 AS DOUBLE PRECISION) FROM
RDB$DATABASE');
echo $query->fetchColumn();
Expected result:
----------------
25.3639309364232
Actual result:
--------------
25.363931
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77192&edit=1
Thread (2 messages)