{"id":691,"date":"2009-05-22T04:05:06","date_gmt":"2009-05-21T20:05:06","guid":{"rendered":"http:\/\/fdream.net\/blog\/article\/691.aspx"},"modified":"2009-05-22T05:05:25","modified_gmt":"2009-05-21T21:05:25","slug":"%e5%85%b3%e4%ba%8eMath.PI%e3%80%81%e5%89%8d%e8%87%aa%e5%a2%9e%e5%92%8c%e5%90%8e%e8%87%aa%e5%a2%9e","status":"publish","type":"post","link":"https:\/\/fdream.net\/blog\/article\/691","title":{"rendered":"\u5173\u4e8eMath.PI\u3001\u524d\u81ea\u589e\u548c\u540e\u81ea\u589e"},"content":{"rendered":"<p>\u6709\u8fd9\u4e48\u4e00\u4e2a\u9898\u76ee\uff0c\u8bf4bt\u5176\u5b9e\u4e5f\u4e0dbt\uff0c\u4e3a\u4e86\u91cd\u70b9\u7a81\u51fa\u5176\u4e2d\u7684\u610f\u56fe\uff0c\u7279\u610f\u52a0\u4e0a\u4e86\u62ec\u53f7\uff1a<\/p>\n<p><pre lang=\"javascript\">\nvar a = (++Math.PI);\nvar b = (Math.PI++);\nvar c = Math.PI = (++Math.PI);\nvar d = Math.PI = (Math.PI++);\nvar e = Math.PI = (Math.PI + 1);\n<\/pre>\n<\/p>\n<p>\u6267\u884c\u5b8c\u540e\uff0ca\u3001b\u3001c\u3001d\u3001e\u7684\u503c\u5206\u522b\u662f\u4ec0\u4e48\u5462\uff1f\u5982\u679c\u5b66\u6821\u91cc\u5b66\u7684C\u8bed\u8a00\u57fa\u7840\u597d\u7684\u8bdd\uff0c\u5e94\u8be5\u53ef\u4ee5\u77e5\u9053\u7b54\u6848\u3002\u4f60\u4e0d\u59a8\u5148\u5199\u4e0b\u7b54\u6848\uff0c\u6211\u4eec\u518d\u6765\u770b\u770bECMA\u7684\u89c4\u8303\u3002<\/p>\n<p>\u5728ECMA-262\u4e2d\uff0c\u5bf9\u4e8eMath.PI\u7684\u8bf4\u660e\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<blockquote>\n<p><b>15.8.1.6<\/b><\/p>\n<p>The number value for \u03c0, the ratio of the circumference of a circle to its diameter, which is approximately 3.1415926535897932.<\/p>\n<p>This property has the attributes { DontEnum, DontDelete, ReadOnly }.<\/p>\n<\/blockquote>\n<p>\u5f88\u6e05\u695a\uff0cReadOnly\uff0c\u90a3\u4e48\u4f60\u7ed9Math.PI\u8d4b\u503c\u662f\u6ca1\u6709\u7528\u7684\u3002<\/p>\n<p>\u518d\u770b\u770b\u5173\u4e8e\u524d\u81ea\u589e\uff08Prefix Increment\uff09\uff1a<\/p>\n<blockquote>\n<p><b>11.4.4 Prefix Increment Operator<\/b><\/p>\n<p>The production UnaryExpression : ++ UnaryExpression is evaluated as follows:<\/p>\n<p>1. Evaluate UnaryExpression.<br \/>2. Call GetValue(Result(1)).<br \/>3. Call ToNumber(Result(2)).<br \/>4. Add the value 1 to Result(3), using the same rules as for the + operator (see 11.6.3).<br \/>5. Call PutValue(Result(1), Result(4)).<br \/>6. Return Result(4).<\/p>\n<\/blockquote>\n<p>\u6ce8\u610f\uff0c\u524d\u81ea\u589e\u8fd4\u56de\u7684\u662f\u7b2c\u56db\u6b65\u7684\u7ed3\u679c\uff0c\u4e5f\u5c31\u662f\u81ea\u589e1\u4ee5\u540e\u7684\u503c\u3002\u56e0\u6b64\uff0c\u5bf9\u4e8ea\u6765\u8bf4\uff0c\u5c31\u662f\u5148\u53d6Math.PI\u7684\u503c\uff0c\u7136\u540e\u8f6c\u5316\u4e3aNumber\uff0c\u7136\u540e\u52a01\uff0c\u8fd4\u56de\u7684\u5c31\u662fMath.PI\u7684\u503c\u52a01\u4ee5\u540e\u7684\u7ed3\u679c\u3002\u56e0\u6b64\uff0ca\u662f4.141592653589793.<\/p>\n<p>\u518d\u770b\u770b\u5173\u4e8e\u540e\u7f00\u81ea\u589e\uff08Prefix Increment\uff09\uff1a<\/p>\n<blockquote>\n<p><b>11.3.1 Postfix Increment Operator<\/b><\/p>\n<p>The production PostfixExpression : LeftHandSideExpression [no LineTerminator here] ++ is evaluated as follows:<\/p>\n<p>1. Evaluate LeftHandSideExpression.<br \/>2. Call GetValue(Result(1)).<br \/>3. Call ToNumber(Result(2)).<br \/>4. Add the value 1 to Result(3), using the same rules as for the + operator (see 11.6.3).<br \/>5. Call PutValue(Result(1), Result(4)).<br \/>6. Return Result(3).<\/p>\n<\/blockquote>\n<p>\u548c\u4e0a\u9762\u7684\u4e0d\u540c\uff0c\u8fd4\u56de\u7b2c\u4e09\u6b65\u7684\u7ed3\u679c\uff0c\u5373\u6ca1\u6709\u81ea\u589e\u4e4b\u524d\u7684\u7ed3\u679c\uff0c\u56e0\u6b64\u8fd4\u56de3.141592653589793.<\/p>\n<p>\u518d\u6765\u770b\u770b\u4e24\u4e2a\u8fde\u7eed\u8d4b\u503c\u7684\u4e09\u4e2a\u8868\u8fbe\u5f0f\uff0c\u7531\u4e8e\u8d4b\u503c\u8fd0\u7b97\u662f\u53f3\u7ed3\u5408\u8fd0\u7b97\uff0c\u56e0\u6b64\u8fd9\u4e09\u4e2a\u8868\u8fbe\u5f0f\u76f8\u5f53\u4e8e\uff1a<\/p>\n<p><pre lang=\"javascript\">\nvar c = (Math.PI = (++Math.PI));\nvar d = (Math.PI = (Math.PI++));\nvar e = (Math.PI = (Math.PI + 1));\n<\/pre>\n<\/p>\n<p>\u800c\u5bf9\u4e8e\u8d4b\u503c\u8fd0\u7b97\uff0c\u5728ECMA-262\u4e2d\u662f\u8fd9\u6837\u63cf\u8ff0\u7684\uff1a<\/p>\n<blockquote>\n<p><b>11.13.1 Simple Assignment ( = )<\/b><\/p>\n<p>The production AssignmentExpression : LeftHandSideExpression = AssignmentExpression is evaluated as follows:<\/p>\n<p>1. Evaluate LeftHandSideExpression.<br \/>2. Evaluate AssignmentExpression.<br \/>3. Call GetValue(Result(2)).<br \/>4. Call PutValue(Result(1), Result(3)).<br \/>5. Return Result(3).<\/p>\n<\/blockquote>\n<p>\u8d4b\u503c\u540e\uff0c\u8fd4\u56de\u7b2c\u4e09\u6b65\u7684\u7ed3\u679c\uff0c\u5373\u8bed\u53e5\u53f3\u8fb9\u7684\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u3002\u56e0\u6b64\uff0c\u8fd9\u91ccc\u3001d\u3001e\u7684\u7ed3\u679c\u5c31\u5f88\u660e\u663e\u4e86\uff1a<\/p>\n<p><pre lang=\"javascript\">\nc = 4.141592653589793;\nd = 3.141592653589793;\ne = 4.141592653589793;\n<\/pre>\n<\/p>\n<p>\u8fd9\u91cc\u8fd8\u8981\u6ce8\u610f\u4e00\u70b9\u4ec0\u4e48\uff1fa++ \u548c a=a+1 \u4e0d\u4e00\u6837\uff5e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u8fd9\u4e48\u4e00\u4e2a\u9898\u76ee\uff0c\u8bf4bt\u5176\u5b9e\u4e5f\u4e0dbt\uff0c\u4e3a\u4e86\u91cd\u70b9\u7a81\u51fa\u5176\u4e2d\u7684\u610f\u56fe\uff0c\u7279\u610f\u52a0\u4e0a\u4e86\u62ec\u53f7\uff1a var a = (++Math.PI); var b = (Math.PI++); var c = Math.PI = (++Math.PI); var d = Math.PI = (Math.PI++); var e = Math.PI = (Math.PI + 1); \u6267\u884c\u5b8c\u540e\uff0ca\u3001b\u3001c\u3001d\u3001e\u7684\u503c\u5206\u522b\u662f\u4ec0\u4e48\u5462\uff1f\u5982\u679c\u5b66\u6821\u91cc\u5b66\u7684C\u8bed\u8a00\u57fa\u7840\u597d\u7684\u8bdd\uff0c\u5e94\u8be5\u53ef\u4ee5\u77e5\u9053\u7b54\u6848\u3002\u4f60\u4e0d\u59a8\u5148\u5199\u4e0b\u7b54\u6848\uff0c\u6211\u4eec\u518d\u6765\u770b\u770bECMA\u7684\u89c4\u8303\u3002 \u5728ECMA-262\u4e2d\uff0c\u5bf9\u4e8eMath.PI\u7684\u8bf4\u660e\u662f\u8fd9\u6837\u7684\uff1a 15.8.1.6 The number value for \u03c0, the ratio of the circumference of a circle to its diameter, which is approximately 3.1415926535897932. This property has &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[104],"class_list":["post-691","post","type-post","status-publish","format-standard","hentry","category-coding","tag-JavaScript"],"views":8059,"_links":{"self":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/comments?post=691"}],"version-history":[{"count":0,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/691\/revisions"}],"wp:attachment":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/media?parent=691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/categories?post=691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/tags?post=691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}