{"id":1885,"date":"2024-11-10T14:50:03","date_gmt":"2024-11-10T06:50:03","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1885\/"},"modified":"2024-11-10T14:50:03","modified_gmt":"2024-11-10T06:50:03","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-javascript-%e5%9c%a8%e4%bf%9d%e7%95%99%e5%85%ad%e4%bd%8d%e5%b0%8f%e6%95%b0%e7%9a%84%e5%90%8c%e6%97%b6%e5%8e%bb%e9%99%a4%e5%a4%9a%e4%bd%99%e7%9a%84-0%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1885\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 JavaScript \u5728\u4fdd\u7559\u516d\u4f4d\u5c0f\u6570\u7684\u540c\u65f6\u53bb\u9664\u591a\u4f59\u7684 0\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173060983226080.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 JavaScript \u5728\u4fdd\u7559\u516d\u4f4d\u5c0f\u6570\u7684\u540c\u65f6\u53bb\u9664\u591a\u4f59\u7684 0\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 JavaScript \u5728\u4fdd\u7559\u516d\u4f4d\u5c0f\u6570\u7684\u540c\u65f6\u53bb\u9664\u591a\u4f59\u7684 0\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5c0f\u6570\u70b9\u4fdd\u7559\u516d\u4f4d\uff1a\u81ea\u52a8\u53bb\u9664\u5c0f\u6570\u70b9\u540e\u591a\u4f59\u7684 0<\/strong><\/p>\n<p>\u5728 javascript \u4e2d\uff0ctofixed() \u65b9\u6cd5\u53ef\u4ee5\u5c06\u6570\u5b57\u683c\u5f0f\u5316\u4e3a\u5b57\u7b26\u4e32\uff0c\u4fdd\u7559\u6307\u5b9a\u4f4d\u6570\u7684\u5c0f\u6570\u3002\u7136\u800c\uff0c\u5b83\u4fdd\u7559\u4e86\u6240\u6709\u5c0f\u6570\u4f4d\uff0c\u5373\u4f7f\u5b83\u4eec\u662f 0\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u4fdd\u7559\u516d\u4f4d\u5c0f\u6570\uff0c\u540c\u65f6\u81ea\u52a8\u53bb\u9664\u540e\u8fb9\u7684 0\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<pre>Math.round(num * 1000000) \/ 1000000<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u4e2a\u65b9\u6cd5\u5c06\u6570\u5b57\u4e58\u4ee5 1000000\uff0c\u4f7f\u5c0f\u6570\u70b9\u540e\u6709\u516d\u4f4d\u6570\u5b57\uff0c\u7136\u540e\u9664\u4ee5 1000000\uff0c\u4ee5\u5220\u9664\u591a\u4f59\u7684 0\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u5982\u679c\u6570\u5b57\u662f\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ul>\n<li>1111.1\uff0c\u8f93\u51fa\u5c06\u662f &#8220;1111.1&#8221;<\/li>\n<li>0.0003452\uff0c\u8f93\u51fa\u5c06\u662f &#8220;0.000345&#8221;<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 JavaScript \u5728\u4fdd\u7559\u516d\u4f4d\u5c0f\u6570\u7684\u540c\u65f6\u53bb\u9664\u591a\u4f59\u7684 0\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c0f\u6570\u70b9\u4fdd\u7559\u516d\u4f4d\uff1a\u81ea\u52a8\u53bb\u9664\u5c0f\u6570\u70b9\u540e\u591a\u4f59\u7684 0 \u5728 javascript \u4e2d\uff0ctofixed() \u65b9\u6cd5\u53ef\u4ee5\u5c06\u6570\u5b57\u683c\u5f0f\u5316\u4e3a\u5b57\u7b26\u4e32\uff0c\u4fdd\u7559\u6307\u5b9a\u4f4d\u6570\u7684\u5c0f\u6570\u3002\u7136\u800c\uff0c\u5b83\u4fdd\u7559\u4e86\u6240\u6709\u5c0f\u6570\u4f4d\uff0c\u5373\u4f7f\u5b83\u4eec\u662f 0\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u4fdd\u7559\u516d\u4f4d\u5c0f\u6570\uff0c\u540c\u65f6\u81ea\u52a8\u53bb\u9664\u540e\u8fb9\u7684 0\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a Math.round(num * 1000000) \/ 1000000 \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u4e2a\u65b9\u6cd5\u5c06\u6570\u5b57\u4e58\u4ee5 1000000\uff0c\u4f7f\u5c0f\u6570\u70b9\u540e\u6709\u516d\u4f4d\u6570\u5b57\uff0c\u7136\u540e\u9664\u4ee5 1000000\uff0c\u4ee5\u5220\u9664\u591a\u4f59\u7684 0\u3002 \u56e0\u6b64\uff0c\u5982\u679c\u6570\u5b57\u662f\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b 1111.1\uff0c\u8f93\u51fa\u5c06\u662f &#8220;1111.1&#8221; 0.0003452\uff0c\u8f93\u51fa\u5c06\u662f &#8220;0.000345&#8221; \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 JavaScript \u5728\u4fdd\u7559\u516d\u4f4d\u5c0f\u6570\u7684\u540c\u65f6\u53bb\u9664\u591a\u4f59\u7684 0\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1885","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=1885"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1885\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}