php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77192 Rounding of double precision column
Submitted: 2018-11-23 13:54 UTC Modified: 2020-12-23 12:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: celiorod21 at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: PDO Firebird
PHP Version: 7.2.12 OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
45 + 10 = ?
Subscribe to this entry?

 
 [2018-11-23 13:54 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-23 12:22 UTC] cmb@php.net
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.
 [2020-12-23 12:22 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Sep 22 20:03:39 2021 UTC