#31180 [Opn]: 4.3.10 printf(%.2f) precision bug.
| From: | derick@php.net | Date: | Sat, 18 Dec 2004 22:43:49 +0000 |
| Subject: | #31180 [Opn]: 4.3.10 printf(%.2f) precision bug. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-70614@lists.php.net to get a copy of this message | ||
ID: 31180
Updated by: derick@php.net
Reported By: patrick at ilmander dot com
Status: Open
Bug Type: Unknown/Other Function
Operating System: Red Hat Linux
PHP Version: 4.3.10
New Comment:
This works fine here:
$ php-4.3dev -r 'echo sprintf("%.2f", 42.1231213123);'
42.12
Previous Comments:
------------------------------------------------------------------------
[2004-12-18 12:20:20] patrick at ilmander dot com
Printing a variable with %.2f should output the number with 2 decimals.
After upgrading to 4.3.10 it now outputs 3 decimals. %.1f outputs with 2
decimals and I haven't figured out how to print out just 1 decimal (%.0f
doesn't work), so I'm treating this as a bug.
------------------------------------------------------------------------
[2004-12-18 12:18:54] patrick at ilmander dot com
Description:
------------
Printing a variable with %.2f should output the number with 2 decimals.
After upgrading to 4.3.10 it now outputs 3 decimals. %.1f outputs with 2
decimals and I haven't figured out how to print out just 1 decimal (%.1f
doesn't work), so I'm treating this as a bug.
Reproduce code:
---------------
printf("%.2f", $member[score] / $member[votes]);
Expected result:
----------------
1.23
Actual result:
--------------
1.234
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31180&edit=1