|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73447 Floats written to character fields are truncated to integer
Submitted: 2016-11-02 18:42 UTC Modified: 2016-11-02 19:08 UTC
From: Assigned: cmb (profile)
Status: Closed Package: dbase (PECL)
PHP Version: 5.6.27 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2016-11-02 18:42 UTC]
If a float value is written to a character field ('C') all decimals are
discarded, and only the integral part of the number is written. Also,
the number is right padded to the field length. This regression has been
introduced by fixing bug #39305.

Test script:

$filename = __DIR__ . DIRECTORY_SEPARATOR . 'dbase-trunc.dbf';

$db = dbase_create($filename, [['FLOAT', 'C', 15]]);

dbase_add_record($db, [123.45]);
var_dump(dbase_get_record_with_names($db, 1));

Expected result:
array(2) {
  string(15) "123.45         "

Actual result:
array(2) {
  string(15) "            123"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-02 18:42 UTC]
-Assigned To: +Assigned To: cmb
 [2016-11-02 18:55 UTC]
Automatic comment from SVN on behalf of cmb
Log: Fix #73447: Floats written to character fields are truncated to integer

We must not apply _php_math_number_format_ex() on fields where db_fdc
doesn't have a meaningful value. Instead we can rely on normal to string
conversion for these cases.
 [2016-11-02 19:08 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Jun 07 02:01:26 2020 UTC