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
 [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 05:01:34 2025 UTC