{"id":3102,"date":"2017-06-02T10:00:03","date_gmt":"2017-06-02T01:00:03","guid":{"rendered":"https:\/\/www.sria.co.jp\/blog\/?p=3102"},"modified":"2017-06-20T11:31:58","modified_gmt":"2017-06-20T02:31:58","slug":"math","status":"publish","type":"post","link":"https:\/\/www.sria.co.jp\/blog\/2017\/06\/math\/","title":{"rendered":"\u7b2c3\u56de  \u30a8\u30c7\u30a3\u30bf\u30fc\u304c\u5b66\u3076\u521d\u3081\u3066\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\uff08JavaScript\u7de8 \u30e9\u30f3\u30c0\u30e0\u306a\u6574\u6570\u3092\u51fa\u529b\u3059\u308b\uff09"},"content":{"rendered":"<p>SRIA\u30a8\u30c7\u30a3\u30bf\u30fc\u306e\u308f\u304b\u3084\u306a\u304e\u3067\u3059\u3002\u30a8\u30c7\u30a3\u30bf\u30fc\u304c\u5b66\u3076\u521d\u3081\u3066\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3001\u7b2c3\u56de\u3092\u304a\u9001\u308a\u3057\u307e\u3059\uff01<\/p>\n<p><a href=\"https:\/\/www.sria.co.jp\/blog\/2017\/05\/javascript\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u524d\u56de\uff08\u7b2c2\u56de\uff09<\/a>\u306f\u3001JavaScript\u3092\u4f7f\u3063\u3066\u30b9\u30ed\u30c3\u30c8\u30b2\u30fc\u30e0\u3092\u4f5c\u308a\u307e\u3057\u305f\u3002\u95a2\u6570\u3092\u4f7f\u3063\u3066\u30e9\u30f3\u30c0\u30e0\u306b\u753b\u50cf\u3092\u8868\u793a\u3055\u305b\u3001\u30b9\u30ed\u30c3\u30c8\u306e\u7d75\u67c4\u3092\u52d5\u304b\u3057\u307e\u3057\u305f\u3002<br \/>\n\u7b2c3\u56de\u306f\u3001\u305d\u306e\u969b\u306b\u4f7f\u3063\u305fMath\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u95a2\u6570\u306e2\u3064\u3092\u8abf\u3079\u305f\u8a18\u4e8b\u3067\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>Math\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3063\u3066\uff1f<\/h2>\n<p>\u6570\u5024\u306b\u95a2\u308f\u308b\u3053\u3068\u3092\u3001\u3088\u3057\u306a\u306b\u3057\u3066\u304f\u308c\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3002<br \/>\n\u5c0f\u6570\u70b9\u306e\u5207\u308a\u4e0a\u3052\u30fb\u5207\u308a\u6368\u3066\u304b\u3089\u3001\u5e73\u65b9\u6839\u306e\u8a08\u7b97\u3001sin\/cos\/tan\u306e\u8a08\u7b97\u307e\u3067\uff01<\/p>\n<p>\u524d\u56de\u306e\u30b9\u30ed\u30c3\u30c8\u30b2\u30fc\u30e0\u3067\u4f7f\u7528\u3057\u305f\u306e\u306f\u3001\u4ee5\u4e0b\u306e2\u3064\u3002<\/p>\n<ul>\n<li>Math.random<\/li>\n<li>Math.floor<\/li>\n<\/ul>\n<p>\u3069\u3093\u306a\u52d5\u304d\u3092\u3059\u308b\u304b\u3001\u3092\u4ee5\u4e0b\u306b\u307e\u3068\u3081\u307e\u3057\u305f\u3002<\/p>\n<h2>Math.random\u95a2\u6570<\/h2>\n<p>Math.random\u95a2\u6570\u306f\u30010\u304b\u30891\u672a\u6e80\u306e\u9593\u3067\u3001\u30e9\u30f3\u30c0\u30e0\u306a\u6570\u5b57\u3092\u751f\u6210\u3059\u308b\u95a2\u6570\u3067\u3059\u3002<br \/>\n\u5b9f\u884c\u3059\u308b\u3068\u3001\u3053\u3093\u306a\u98a8\u306b\u6570\u5024\u304c\u5f97\u3089\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true\">&gt;Math.random();\r\n0.08101679106330328\r\n&gt;Math.random();\r\n0.9850375356721648\r\n&gt;Math.random();\r\n0.3323284928910797\r\n...<\/pre>\n<h2>Math.floor\u95a2\u6570<\/h2>\n<p>Math.floor\u95a2\u6570\u306f\u3001\u5f15\u6570\uff08\u4e0e\u3048\u3089\u308c\u305f\u6570\uff09\u306e\u5c0f\u6570\u70b9\u3092\u5207\u308a\u6368\u3066\u3066\u6574\u6570\u306b\u3059\u308b\u95a2\u6570\u3067\u3059\u3002<\/p>\n<p>\u4e0a\u8a18\u306eMath.random\u95a2\u6570\u3067\u751f\u6210\u3055\u308c\u305f\u6570\u5024\u3092\u3001Math.floor\u95a2\u6570\u3067\u51e6\u7406\u3059\u308b\u3068\u3001<\/p>\n<pre class=\"lang:js decode:true\">&gt;Math.floor(0.08101679106330328);\r\n0\r\n&gt;Math.floor(0.9850375356721648);\r\n0\r\n&gt;Math.floor(0.3323284928910797)\u3000;\r\n0<\/pre>\n<p>\u51fa\u529b\u3055\u308c\u308b\u6570\u5024\u304c0\u304b\u30891<span style=\"text-decoration: underline\">\u672a\u6e80<\/span>\u306a\u306e\u3067\u3001\u5207\u308a\u6368\u3066\u308b\u30680\u306b\u3057\u304b\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u4eca\u56de\u306e\u30b9\u30ed\u30c3\u30c8\u30b2\u30fc\u30e0\u3067\u51fa\u529b\u3057\u305f\u304b\u3063\u305f\u306e\u306f\u3001\u6574\u65701\u304b\u30893\u306e\u3044\u305a\u308c\u304b\u3002<\/p>\n<p>\u3053\u308c\u3092\u5b9f\u73fe\u3055\u305b\u308b\u305f\u3081\u306b\u30012\u3064\u306e\u95a2\u6570\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u52a0\u5de5\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:js decode:true\">Math.floor(Math.random() * 3) ;\r\n<\/pre>\n<p>\u30e9\u30f3\u30c0\u30e0\u751f\u6210\u3055\u308c\u305f\u6570\u5024\u30923\u500d\u3059\u308b\u3068\u3001\u5f97\u3089\u308c\u308b\u306e\u306f0\u304b\u30892\u306e\u3044\u305a\u308c\u304b\u3002<br \/>\n\u307b\u3057\u3044\u6570\u5024\u306f1\u304b\u30893\u306a\u306e\u3067\u3001\u51fa\u305f\u6570\u5024\u306b+1\u3059\u308b\u3068\u30fb\u30fb\u30fb<\/p>\n<pre class=\"lang:js decode:true\">&gt;Math.floor(Math.random() * 3) +1;\r\n1\r\n&gt;Math.floor(Math.random() * 3) +1;\r\n3\r\n&gt;Math.floor(Math.random() * 3) +1;\r\n3\r\n<\/pre>\n<p>\u3067\u304d\u305f\u30fc\uff01\u3053\u308c\u30671\u304b\u30893\u307e\u3067\u306e\u6574\u6570\u304c\u5f97\u3089\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u6574\u7406\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \">Math.floor(Math.random()*(n+1));\u3000\u3000\/\/\u30000\u304b\u3089n\u307e\u3067\u306e\u6574\u6570\u304c\u307b\u3057\u3044\u6642\r\nMath.floor(Math.random()*n )+1; \/\/1\u304b\u3089n\u307e\u3067\u306e\u6574\u6570\u304c\u307b\u3057\u3044\u6642<\/pre>\n<p>\u4ee5\u4e0a\u3001Math.floor\u3068Math.random\u306b\u3064\u3044\u3066\u304a\u9001\u308a\u3057\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SRIA\u30a8\u30c7\u30a3\u30bf\u30fc\u306e\u308f\u304b\u3084\u306a\u304e\u3067\u3059\u3002\u30a8\u30c7\u30a3\u30bf\u30fc\u304c\u5b66\u3076\u521d\u3081\u3066\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3001\u7b2c3\u56de\u3092\u304a\u9001\u308a\u3057\u307e\u3059\uff01 \u524d\u56de\uff08\u7b2c2\u56de\uff09\u306f\u3001JavaScript\u3092\u4f7f\u3063\u3066\u30b9\u30ed\u30c3\u30c8\u30b2\u30fc\u30e0\u3092\u4f5c\u308a\u307e\u3057\u305f\u3002\u95a2\u6570\u3092\u4f7f\u3063\u3066\u30e9\u30f3\u30c0\u30e0\u306b\u753b\u50cf\u3092\u8868\u793a\u3055\u305b\u3001\u30b9\u30ed\u30c3\u30c8&#8230;<\/p>\n","protected":false},"author":5,"featured_media":3042,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14,8],"tags":[],"_links":{"self":[{"href":"https:\/\/www.sria.co.jp\/blog\/wp-json\/wp\/v2\/posts\/3102"}],"collection":[{"href":"https:\/\/www.sria.co.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sria.co.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sria.co.jp\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sria.co.jp\/blog\/wp-json\/wp\/v2\/comments?post=3102"}],"version-history":[{"count":29,"href":"https:\/\/www.sria.co.jp\/blog\/wp-json\/wp\/v2\/posts\/3102\/revisions"}],"predecessor-version":[{"id":3455,"href":"https:\/\/www.sria.co.jp\/blog\/wp-json\/wp\/v2\/posts\/3102\/revisions\/3455"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sria.co.jp\/blog\/wp-json\/wp\/v2\/media\/3042"}],"wp:attachment":[{"href":"https:\/\/www.sria.co.jp\/blog\/wp-json\/wp\/v2\/media?parent=3102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sria.co.jp\/blog\/wp-json\/wp\/v2\/categories?post=3102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sria.co.jp\/blog\/wp-json\/wp\/v2\/tags?post=3102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}