Bug #15151: Decimals/Numerics stored as int64 always display as xxx.2

From: Date: Mon, 21 Jan 2002 18:10:18 +0000
Subject: Bug #15151: Decimals/Numerics stored as int64 always display as xxx.2
Groups: php.dev 
Request: Send a blank email to php-dev+get-77708@lists.php.net to get a copy of this message
From:             mitch@tropical.co.cr
Operating system: Windows
PHP version:      4.1.1
PHP Bug Type:     InterBase related
Bug description:  Decimals/Numerics stored as int64 always display as xxx.2

Decimals/Numerics that are stored as 64-bit integers always display as
xxx.2.

The following should fix the problem:

Original code (on or about line 1782):

val->value.str.len = sprintf(string_data, "%Ld.%0*Ld",
     (ISC_INT64) (*((ISC_INT64 *)data) /
     (int) pow(10.0, (double) -scale)),
     -scale,
     (ISC_INT64) abs((int) (*((ISC_INT64 *)data) %
     (int) pow(10.0, (double) -scale))));

Change to:
val->value.str.len = sprintf(string_data, "%Ld",
     (ISC_INT64) (*((ISC_INT64 *)data) /
     (int) pow(10.0, (double) -scale)));
val->value.str.len += sprintf(string_data +
     val->value.str.len, ".%0*Ld",
     -scale,
    (ISC_INT64) abs((int) (*((ISC_INT64 *)data) %
    (int) pow(10.0, (double) -scale))));



The problem is with MSVC++.  It doesn't seem to like two int64s in the
same sprintf statement.  I don't yet have all the pieces to compile the
extension so I have not fully tested it, but I have duplicated the problem
in a test program and verified that the above code fixes the problem in
the test program.
-- 
Edit bug report at: http://bugs.php.net/?id=15151&edit=1



Thread (2 messages)

« previous php.dev (#77708) next »