自然対数を返します.
Math.log(x)
logメソッドはxの自然対数(logEx)を返します.
xが負の値である場合,logメソッドはNaNを返します.
以下にlogメソッドを使用したサンプルコードを示します.
<html>
<head>
<title>logメソッドのサンプルコード</title>
</head>
<body>
<script type="text/javascript" language="javascript">
document.write(Math.log(1) + "<br />");
document.write(Math.log(2) + "<br />");
document.write(Math.log(Math.E) + "<br />");
document.write(Math.log(0) + "<br />");
document.write(Math.log(-1) + "<br />");
</script>
</body>
</html>
サンプルコードの実行結果は以下のようになります.
0 0.6931471805599453 1 -Infinity NaN
スポンサード リンク