ID:               28228
 User updated by:  bichinhoverde at spwinternet dot com dot br
 Reported By:      bichinhoverde at spwinternet dot com dot br
 Status:           Open
 Bug Type:         Unknown/Other Function
 Operating System: windows and linux
 PHP Version:      4.3.6
 New Comment:

Just in case someone finds this "feature report", here is a work
around:

number_format(1234.5678*100,0,'','');

It prints "123457" as I wanted.


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

[2004-04-30 03:22:50] bichinhoverde at spwinternet dot com dot br

I was expecting the same behavior for the decimal point and the
thousands separator. If you write:

number_format(1234.5678, 2, 'a', 'b');

It outputs:

1b234a57

Is it understandable? Does it matter?

If you specify no thousands separator, it displays the number without
it. But the same is not true for the decimal point.

These two lines have the same result:
number_format(1234.5678, 2, '', '');
number_format(1234.5678, 2, '.', '');

It shouldn't be, IMHO.

Now, why would I use fractional numbers without the decial point?
Because I must print bank codes that have currency values in them. They
use fixed point (2 decimal places) instead of floating point. So, $
1234,55 will be 123455 in the bank code. Got it?

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

[2004-04-30 03:04:39] [EMAIL PROTECTED]

Oops. Disregard that last comment. What I meant to write 
was:

This is a bug, not a feature. Why would you want to 
print a number without a decimal point? It wouldn't be 
the same number. A number without a thousands separator, 
however, is still understandable.

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

[2004-04-30 03:02:53] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

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

[2004-04-30 02:49:02] bichinhoverde at spwinternet dot com dot br

Description:
------------
When I put an empty string '' as the decimal point in the number_format
function, it uses the dot '.' as decimal point.

The function works well for the thousands separator.

Reproduce code:
---------------
print number_format(1234.5678, 2, '', '');


Expected result:
----------------
123457

Actual result:
--------------
1234.57


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


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

Reply via email to