Mathオブジェクト

Posted by poundhound on

いつも忘れてしまうので自分のための覚え書き。

Math.random()...0〜0.999...9までの値をランダムに所得する。Math.floor()は小数点以下を切り捨て、Math.ceil()は小数点以下を切り上げ、Math.round()は少数点以下を四捨五入する。

Math.floor(Math.random()*10)+1; または Math.ceil(Math.random()*10) で1〜10までのランダムな整数を生成する。

Categories: Web Tags: ,

Comment(0) | Trackback(0)

Category:Web の最近の記事

Trackback(0)

Trackback URL: http://www.nk0206.com/mt5/mt-tb.cgi/358

Leve comment

About Author

poundhound

poundhound
web-designer
  • del.icio.us
  • flickr
  • Last FM
  • tumblr

twitter

Recent Tweet

    follow me on twitter

    Life Log

    • twilog
    • twitpic
    • pick