|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
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-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 16 01:01:28 2024 UTC