Bug #47418 [Com]: number_format misbehaving with some values

From: Date: Tue, 30 Nov 2010 22:23:17 +0000
Subject: Bug #47418 [Com]: number_format misbehaving with some values
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-156604@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=47418&edit=1

 ID:                 47418
 Comment by:         carrieraglan at gmail dot com
 Reported by:        cu19 at gmx dot de
 Summary:            number_format misbehaving with some values
 Status:             No Feedback
 Type:               Bug
 Package:            *Math Functions
 Operating System:   Win7
 PHP Version:        5.3.1
 Block user comment: N
 Private report:     N

 New Comment:

Apache/2.2.11 
PHP/5.2.10

$sql = "SELECT FIELD_1 FROM DB2_TABLE WHERE ID = ?";
$cur = odbc_prepare($db_handle, $sql);
odbc_execute($cur, array(20382));
$field_1 = odbc_result($cur, "FIELD_1");
$field_1 = trim($field_1);
print "<br>".$field_1;
print "<br>".number_format($field_1, 2, '.', '');
print "<br>".number_format($field_1, 2, '.', ',');

Expected Result:
1.90000000000000E+001
19.00
19.00

Actual Result:
1.90000000000000E+001
18.:0
18.:0


Previous Comments:
------------------------------------------------------------------------
[2010-07-17 05:53:42] adrianv at taly dot net

Code to reproduce this, where lib.php contains the my_number_format
function as described by cu19 at gmx dot de. Numbers are internally
correct, but display incorrectly.

<?php

	include_once("lib.php");

 	echo "== Demo 1 == <BR>";

	$deb = 10.50;
	$crd = 1;
	$tot = 0;

	for ($t=1;$t<=300;$t++) {
		$tot += $deb - $crd;
		echo "$t  $tot";
		echo " >>>> ";
		echo strval($tot);
		echo " >>>> ";
		echo sprintf('%F',$tot);
		echo " >>>> ";
		echo number_format($tot,2);
		echo " >>>> ";
		echo my_number_format($tot,2);
		echo " >>>> ";
		echo "<BR>";
	}
?>

------------------------------------------------------------------------
[2010-03-08 03:37:01] tdietsche at comcast dot net

did you ever get my email?

------------------------------------------------------------------------
[2010-02-20 01:00:00] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------
[2010-02-12 23:01:50] tdietsche at comcast dot net

pajoye: I have just sent you an email with an attached zip, please reply
here or to my email to confirm that you received it, thanks.

------------------------------------------------------------------------
[2010-02-12 19:10:55] tdietsche at comcast dot net

Yes, I will do that and email you a link. The information is
confidential so I must first remove people's personal information first
(names etc). Please remove the file when you are done with it.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=47418


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=47418&edit=1


Thread (24 messages)

« previous php.bugs (#156604) next »