php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35442 printf rounding error
Submitted: 2005-11-28 12:26 UTC Modified: 2005-11-28 12:31 UTC
From: yag_kawa at yahoo dot co dot jp Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.1.0 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: yag_kawa at yahoo dot co dot jp
New email:
PHP Version: OS:

 

 [2005-11-28 12:26 UTC] yag_kawa at yahoo dot co dot jp
Description:
------------
printf %f rounding error

Reproduce code:
---------------
<?php
$a=43.65;
printf("%6.1f",$s);
?>


Expected result:
----------------
43.6

Actual result:
--------------
43.7

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-28 12:31 UTC] tony2001@php.net
printf() doesn't *round* anything.
Use round() for that.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 09:01:31 2025 UTC