#47418 [Com]: number_format misbehaving with some values

From: Date: Fri, 12 Feb 2010 23:01:50 +0000
Subject: #47418 [Com]: number_format misbehaving with some values
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-147539@lists.php.net to get a copy of this message
 ID:               47418
 Comment by:       tdietsche at comcast dot net
 Reported By:      cu19 at gmx dot de
 Status:           Feedback
 Bug Type:         *Math Functions
 Operating System: Win7
 PHP Version:      5.3.1
 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------

[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.

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

[2010-02-12 14:18:15] pajoye@php.net

It could be an encoding issue then (before it gets formatted). Can you
zip the script and the excel file you use and post a link to it here? Or
drop me a mail.

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

[2010-02-12 14:15:30] tdietsche at comcast dot net

I am not sure what you mean by "isolate the value which causes problems
and pass it directly to number_format". If I just assign 19 to a
variable (either as a string or as a number) and do this, it works fine.
It is only when it comes from a result row value of a number-formatted
excel spreadsheet cell that it shows the problem, for me.

You could try a much simpler spreadsheet but I gave all the details of
the one I am using that shows the problem, in case for some reason the
spreadsheet details are related somehow (probably not though).

I don't have time to install a new version of php right now, maybe
later. I have already spent more time on this than I can afford.

One other note, I see in playing around I changed some variable names
in one function, it should really read:

function FmtAmt($amt) {
  // another workaround for the total
  if ((string)$amt == '18.:') $amt = '19';  
  $cred = '    ';
  if ($amt < 0) {
    $amt  = 0 - $amt;
    $cred = 'CR';
  }
  // uncomment this and comment out next line to see bug
  // $ret = number_format($amt, 2) . $cred;  
  $ret = stupid_php($amt) . $cred;
  return $ret;
}

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

[2010-02-12 14:07:58] pajoye@php.net

Can you try to isolate the value which causes problems and pass it
directly to number_format? That will be easier to debug and fix.

Can you aslo try using 5.3.2RC2 (VC9 builds if possible, via CLI or
using apachelounge.com's apache).

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

[2010-02-12 13:32:28] tdietsche at comcast dot net

In case it might help, here is my php config (on WinXP SP3):


  PHP Version 5.3.1


System 	Windows NT DIY2004 5.1 build 2600 (Windows XP Professional
Service Pack 3) i586
Build Date 	Nov 19 2009 10:16:45
Compiler 	MSVC6 (Visual C++ 6.0)
Architecture 	x86
Configure Command 	cscript /nologo configure.js
"--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack"
"--disable-isapi"
"--with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared"
"--with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared"
"--with-oci8-11g=D:\php-sdk\oracle\instantclient11\sdk,shared"
"--enable-object-out-dir=../obj/"
Server API 	Apache 2.0 Handler
Virtual Directory Support 	enabled
Configuration File (php.ini) Path 	C:\WINDOWS
Loaded Configuration File 	C:\PHP\php.ini
Scan this dir for additional .ini files 	(none)
Additional .ini files parsed 	(none)
PHP API 	20090626
PHP Extension 	20090626
Zend Extension 	220090626
Zend Extension Build 	API220090626,TS,VC6
PHP Extension Build 	API20090626,TS,VC6
Debug Build 	no
Thread Safety 	enabled
Zend Memory Manager 	enabled
Zend Multibyte Support 	disabled
IPv6 Support 	enabled
Registered PHP Streams 	php, file, glob, data, http, ftp, zip,
compress.zlib, compress.bzip2, https, ftps, phar
Registered Stream Socket Transports 	tcp, udp, ssl, sslv3, sslv2, tls
Registered Stream Filters 	convert.iconv.*, string.rot13,
string.toupper, string.tolower, string.strip_tags, convert.*,
consumed,
dechunk, zlib.*, bzip2.*

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

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/47418

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



Thread (24 messages)

« previous php.bugs (#147539) next »