note 128781 added to language.types.float
| From: | 251701981 at qq dot com | Date: | Sat, 05 Aug 2023 03:58:56 +0000 |
| Subject: | note 128781 added to language.types.float | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220741@lists.php.net to get a copy of this message | ||
<?php
//Please consider the following code
printf("%.53f\n",0.7+0.1); // 0.79999999999999993338661852249060757458209991455078125
var_dump(0.7+0.1); // float(0.8)
var_dump(0.799999999999999); //float(0.8)
var_dump(0.7999999); // float(0.7999999)
//Conclusion: PHP can support up to 53 decimal places, but in some output functions such as var_
Dump, when outputting decimals exceeding 14 places, will round off the 15th place, which causes
significant misleading
//experimental environmentï¼linux x64ï¼php7.2.x
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.134 (proxied: 14.19.11.62)
----
Manual Page -- https://php.net/manual/en/language.types.float.php
Edit -- https://main.php.net/note/edit/128781
Del: integrated -- https://main.php.net/note/delete/128781/integrated
Del: useless -- https://main.php.net/note/delete/128781/useless
Del: bad code -- https://main.php.net/note/delete/128781/bad+code
Del: spam -- https://main.php.net/note/delete/128781/spam
Del: non-english -- https://main.php.net/note/delete/128781/non-english
Del: in docs -- https://main.php.net/note/delete/128781/in+docs
Del: other reasons-- https://main.php.net/note/delete/128781
Reject -- https://main.php.net/note/reject/128781
Search -- https://main.php.net/manage/user-notes.php