note 116905 added to function.printf
| From: | creating dot www at gmail dot com | Date: | Wed, 18 Mar 2015 13:29:38 +0000 |
| Subject: | note 116905 added to function.printf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201978@lists.php.net to get a copy of this message | ||
Why rounding is not same as for round()?
Try this code:
<?php
printf("%.02lf\n", 1.035);
printf("%.02lf\n", round(1.035, 2));
?>
Result:
1.03
1.04
In my opion it should be:
1.04
1.04
Why is that?
----
Server IP: 72.52.91.14
Probable Submitter: 83.20.164.167
----
Manual Page -- http://php.net/manual/en/function.printf.php
Edit -- https://master.php.net/note/edit/116905
Del: integrated -- https://master.php.net/note/delete/116905/integrated
Del: useless -- https://master.php.net/note/delete/116905/useless
Del: bad code -- https://master.php.net/note/delete/116905/bad+code
Del: spam -- https://master.php.net/note/delete/116905/spam
Del: non-english -- https://master.php.net/note/delete/116905/non-english
Del: in docs -- https://master.php.net/note/delete/116905/in+docs
Del: other reasons-- https://master.php.net/note/delete/116905
Reject -- https://master.php.net/note/reject/116905
Search -- https://master.php.net/manage/user-notes.php