|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-06-02 20:24 UTC] russ at zerotech dot net
number_format() returns 0, all the time, regardless of what was entered.
russ@milton:~$ php -r 'echo number_format(400); echo "\n";';
0
russ@milton:~$ php -r 'echo number_format(600); echo "\n";';
0
russ@milton:~$ php -r 'echo number_format(600, 2); echo "\n";';
0.00
russ@milton:~$ php -r 'echo number_format(600, 5); echo "\n";';
0.00000
russ@milton:~$ php -r 'echo number_format("600", 5); echo "\n";';
0.00000
russ@milton:~$
Also affects the Apache SAPI module, obviously since they make the call to the same function. Worked fine of course in 4.3.1. I just recently upgraded to 4.3.2 and noticed it stopped working.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 05:00:02 2025 UTC |
I compiled the snapshot, no compiler optimizations, and I enabled debugging. My GCC version is: gcc version 3.2.3 20030422 (Gentoo Linux 1.4 3.2.3-r1, propolice). Perhaps it's propolice causing it? As of PHP 4.3.1 though, compiled with propolice, everything worked fine. I still get the same problem with number_format() with the snapshow from today. russ@milton:~/php4-STABLE-200306031330/sapi/cli$ ./php -r 'echo number_format(4000,2); echo "\n";' 0.00 russ@milton:~/php4-STABLE-200306031330/sapi/cli$ ./php -r 'echo number_format(0,2); echo "\n";' 0.00 russ@milton:~/php4-STABLE-200306031330/sapi/cli$ ./php -r 'echo number_format(230,2); echo "\n";' 0.00 russ@milton:~/php4-STABLE-200306031330/sapi/cli$ ./php -r 'echo number_format(234440,2); echo "\n";' 0.00 russ@milton:~/php4-STABLE-200306031330/sapi/cli$ ./php -r 'echo number_format("234440",2); echo "\n";' 0.00 russ@milton:~/php4-STABLE-200306031330/sapi/cli$ gdb --args ./php -r 'echo number_format("234440",2); echo "\n";' To make absolutely sure I'm not doing something different, I compiled PHP 4.3.1 again, the same way I compiled 4.3.2 and the daily SNAPSHOT, these are the results I get: russ@milton:~/php-4.3.1/sapi/cli$ ./php -r 'echo number_format(500); echo "\n";' 500 russ@milton:~/php-4.3.1/sapi/cli$ ./php -r 'echo number_format(500); echo "\n";' 500 russ@milton:~/php-4.3.1/sapi/cli$ ./php -r 'echo number_format(7500); echo "\n";' 7,500 russ@milton:~/php-4.3.1/sapi/cli$ ./php -r 'echo number_format(7500,2); echo "\n";' 7,500.00 Obviously since it doesn't crash I can't bt on the core, but I set a breakpoint at the first call to spprintf which appears to be the major difference in _php_math_number_function() in math.c between 4.3.1 and 4.3.2. It breaks at the first call which is made from _php_math_number_function(). russ@milton:~/php4-STABLE-200306031330/sapi/cli$ gdb --args ./php -r 'echo number_format("234440",2); echo "\n";' GNU gdb 5.3 Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i686-pc-linux-gnu"... (gdb) break spprintf Breakpoint 1 at 0x8128f55: file /home/russ/php4-STABLE-200306031330/main/spprintf.c, line 641. (gdb) run Starting program: /home/russ/php4-STABLE-200306031330/sapi/cli/php -r echo\ number_format\(\"234440\",2\)\;\ echo\ \"\\n\"\; Breakpoint 1, spprintf (pbuf=0xbffff3a8, max_len=0, format=0x8183b58 "%.*f") at /home/russ/php4-STABLE-200306031330/main/spprintf.c:641 641 va_start(ap, format); (gdb) bt #0 spprintf (pbuf=0xbffff3a8, max_len=0, format=0x8183b58 "%.*f") at /home/russ/php4-STABLE-200306031330/main/spprintf.c:641 #1 0x080cb73a in _php_math_number_format (d=234440, dec=2, dec_point=46 '.', thousand_sep=44 ',') at /home/russ/php4-STABLE-200306031330/ext/standard/math.c:997 #2 0x080cbd1c in zif_number_format (ht=2, return_value=0x81ee2fc, this_ptr=0x0, return_value_used=1) at /home/russ/php4-STABLE-200306031330/ext/standard/math.c:1101 #3 0x0816d0a8 in execute (op_array=0x81edf5c) at /home/russ/php4-STABLE-200306031330/Zend/zend_execute.c:1606 #4 0x08151f13 in zend_eval_string (str=0xbffff97d "echo number_format(\"234440\",2); echo \"\\n\";", retval_ptr=0x0, string_name=0x81a88b4 "Command line code") at /home/russ/php4-STABLE-200306031330/Zend/zend_execute_API.c:636 #5 0x08173613 in main (argc=3, argv=0xbffff804) at /home/russ/php4-STABLE-200306031330/sapi/cli/php_cli.c:859 #6 0x400b2767 in __libc_start_main () from /lib/libc.so.6 (gdb) Let me know if you need anything else. I can provide a shell with access to compiler and sources if you'd like.