{"id":350,"date":"2020-02-04T22:56:45","date_gmt":"2020-02-04T14:56:45","guid":{"rendered":"https:\/\/blog.cqdefxxx.com\/?p=350"},"modified":"2020-02-04T22:56:45","modified_gmt":"2020-02-04T14:56:45","slug":"math%e5%af%b9%e8%b1%a1","status":"publish","type":"post","link":"https:\/\/blog.viter.top\/index.php\/2020\/02\/04\/math%e5%af%b9%e8%b1%a1\/","title":{"rendered":"Math\u5bf9\u8c61"},"content":{"rendered":"<pre class=\"pure-highlightjs\"><code class=\"\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n\t&lt;head&gt;\n\t\t&lt;meta charset=\"UTF-8\"&gt;\n\t\t&lt;title&gt;&lt;\/title&gt;\n\t\t&lt;script type=\"text\/javascript\"&gt;\n\t\t\t\/*\n\t\t\t * Math\n\t\t\t * \t- Math\u548c\u5176\u4ed6\u7684\u5bf9\u8c61\u4e0d\u540c\uff0c\u5b83\u4e0d\u662f\u4e00\u4e2a\u6784\u9020\u51fd\u6570\uff0c\n\t\t\t * \t\t\u5b83\u5c5e\u4e8e\u4e00\u4e2a\u5de5\u5177\u7c7b\u4e0d\u7528\u521b\u5efa\u5bf9\u8c61\uff0c\u5b83\u91cc\u8fb9\u5c01\u88c5\u4e86\u6570\u5b66\u8fd0\u7b97\u76f8\u5173\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\n\t\t\t * \t- \u6bd4\u5982\n\t\t\t * \t\tMath.PI \u8868\u793a\u7684\u5706\u5468\u7387\n\t\t\t *\/\n\t\t\t\n\t\t\t\/\/console.log(Math.PI);\n\t\t\t\n\t\t\t\/*\n\t\t\t * abs()\u53ef\u4ee5\u7528\u6765\u8ba1\u7b97\u4e00\u4e2a\u6570\u7684\u7edd\u5bf9\u503c\n\t\t\t *\/\n\t\t\t\/\/console.log(Math.abs(-1));\n\t\t\t\n\t\t\t\/*\n\t\t\t * Math.ceil()\n\t\t\t * \t- \u53ef\u4ee5\u5bf9\u4e00\u4e2a\u6570\u8fdb\u884c\u5411\u4e0a\u53d6\u6574\uff0c\u5c0f\u6570\u4f4d\u53ea\u6709\u6709\u503c\u5c31\u81ea\u52a8\u8fdb1\n\t\t\t * Math.floor()\n\t\t\t * \t- \u53ef\u4ee5\u5bf9\u4e00\u4e2a\u6570\u8fdb\u884c\u5411\u4e0b\u53d6\u6574\uff0c\u5c0f\u6570\u90e8\u5206\u4f1a\u88ab\u820d\u6389\n\t\t\t * Math.round()\n\t\t\t * \t- \u53ef\u4ee5\u5bf9\u4e00\u4e2a\u6570\u8fdb\u884c\u56db\u820d\u4e94\u5165\u53d6\u6574\n\t\t\t *\/\n\t\t\t\/\/console.log(Math.ceil(1.1));\n\t\t\t\/\/console.log(Math.floor(1.99));\n\t\t\t\/\/console.log(Math.round(1.4));\n\t\t\t\n\t\t\t\/*\n\t\t\t * Math.random()\n\t\t\t * \t- \u53ef\u4ee5\u7528\u6765\u751f\u6210\u4e00\u4e2a0-1\u4e4b\u95f4\u7684\u968f\u673a\u6570\n\t\t\t *  - \u751f\u6210\u4e00\u4e2a0-10\u7684\u968f\u673a\u6570\n\t\t\t * \t- \u751f\u6210\u4e00\u4e2a0-x\u4e4b\u95f4\u7684\u968f\u673a\u6570\n\t\t\t * \t\tMath.round(Math.random()*x)\n\t\t\t * \n\t\t\t * \t- \u751f\u6210\u4e00\u4e2a1-10\n\t\t\t * \t- \u751f\u6210\u4e00\u4e2ax-y\u4e4b\u95f4\u7684\u968f\u673a\u6570\n\t\t\t * \t\tMath.round(Math.random()*(y-x)+x)\n\t\t\t *\/\n\t\t\t\/*for(var i=0 ; i&lt;100 ; i++){\n\t\t\t\t\/\/console.log(Math.round(Math.random()*10));\n\t\t\t\t\/\/console.log(Math.round(Math.random()*20));\n\t\t\t\t\n\t\t\t\t\/\/console.log(Math.round(Math.random()*9)+1);\n\t\t\t\t\/\/console.log(Math.round(Math.random()*8)+2);\n\t\t\t\t\n\t\t\t\t\/\/\u751f\u62101-6\u4e4b\u95f4\u7684\u968f\u673a\u6570\n\t\t\t\tconsole.log(Math.round(Math.random()*5+1));\n\t\t\t}*\/\n\t\t\t\n\t\t\t\/*\n\t\t\t * max() \u53ef\u4ee5\u83b7\u53d6\u591a\u4e2a\u6570\u4e2d\u7684\u6700\u5927\u503c\n\t\t\t * min() \u53ef\u4ee5\u83b7\u53d6\u591a\u4e2a\u6570\u4e2d\u7684\u6700\u5c0f\u503c\n\t\t\t *\/\n\t\t\t\n\t\t\tvar max = Math.max(10,45,30,100);\n\t\t\tvar min = Math.min(10,45,30,100);\n\t\t\t\/\/console.log(min);\n\t\t\t\n\t\t\t\/*\n\t\t\t * Math.pow(x,y)\n\t\t\t * \t\u8fd4\u56dex\u7684y\u6b21\u5e42\n\t\t\t *\/\n\t\t\t\n\t\t\t\/\/console.log(Math.pow(12,3));\n\t\t\t\n\t\t\t\/*\n\t\t\t * Math.sqrt()\n\t\t\t *  \u7528\u4e8e\u5bf9\u4e00\u4e2a\u6570\u8fdb\u884c\u5f00\u65b9\u8fd0\u7b97\n\t\t\t *\/\n\t\t\tconsole.log(Math.sqrt(2));\n\t\t\t\n\t\t&lt;\/script&gt;\n\t&lt;\/head&gt;\n\t&lt;body&gt;\n\t&lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset= &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[4],"_links":{"self":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/posts\/350"}],"collection":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/comments?post=350"}],"version-history":[{"count":0,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/posts\/350\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/media?parent=350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/categories?post=350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.viter.top\/index.php\/wp-json\/wp\/v2\/tags?post=350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}