2008-10-20から1日間の記事一覧

三平方の定理はMath.hypot・C言語でも使える

http://rubyist.g.hatena.ne.jp/kusakari/20081020/1224497314Rubyで三平方の定理を使う場合はMath.hypotを使う。hypotはhypotenuse(斜辺)の略。見かけないんだけど、あんま知られてないのかな。組み込みなのにね。 Math.sqrt(3**2 + 4**2) # => 5.0 Math.…