Bug #77192 [Opn->Nab]: Rounding of double precision column

From: Date: Wed, 23 Dec 2020 12:22:07 +0000
Subject: Bug #77192 [Opn->Nab]: Rounding of double precision column
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231229@lists.php.net to get a copy of this message
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)

« previous php.bugs (#231229) next »