ホームページ  >  記事  >  ウェブフロントエンド  >  JS で一般的に使用される数学関数は何ですか?

JS で一般的に使用される数学関数は何ですか?

php中世界最好的语言
php中世界最好的语言オリジナル
2018-05-29 17:56:113168ブラウズ

今回は、JSの一般的な数学関数とは何ですか? 、JS で数学関数を実装するときの 注意事項 は何ですか? 以下は実際的なケースです。見てみましょう。

1. コード

<script language="javascript">
<!--
document.write("欧拉常数e的值为(e属性):"+Math.E+"<br>");
document.write("2的自然对数为(LN2属性):"+Math.LN2+"<br>");//2的几次方等于e
document.write("10的自然对数为(LN10属性):"+Math.LN10+"<br>");//10的几次方等于e
document.write("7的自然对数(log()方法):"+Math.log(7)+"<br>");//7的几次方等于e
document.write("0的自然对数(log()方法):"+Math.log(0)+"<br>");
document.write("-1的自然对数(log()方法):"+Math.log(-1)+"<br>");
document.write("2的自然对数(log()方法):"+Math.log(2)+"<br>");//2的几次方等于e
document.write("以2为基数的e的对数的值:"+Math.LOG2E+"<br>");//E的几次方等于2
document.write("以10为基数的e的对数的值:"+Math.LOG10E+"<br>");//E的几次方等于10
document.write(Math.SQRT1_2);//0.5的平方根
document.write(Math.SQRT2);//2的平方根
document.write("2的平方根:"+Math.sqrt(2)+"<br>");
document.write("4的平方根:"+Math.sqrt(4)+"<br>");
document.write("5的平方根:"+Math.sqrt(5)+"<br>");
document.write("10的平方根:"+Math.sqrt(10));
document.write("-2的绝对值:"+Math.abs(-2)+"<br>");
document.write("0的绝对值:"+Math.abs(0)+"<br>");
document.write("2的绝对值:"+Math.abs(2)+"<br>");
document.write("2.7的绝对值:"+Math.abs(2.7)+"<br>");
document.write("-2.7的绝对值:"+Math.abs(-2.7));
document.write("1的正弦值:"+Math.sin(1)+"<br>");
document.write("0的正弦值:"+Math.sin(0)+"<br>");
document.write("-1的正弦值:"+Math.sin(-1)+"<br>");
document.write("1的反正弦值的正弦值:"+Math.sin(Math.asin(1))+"<br>");
document.write("1的余弦值:"+Math.cos(1)+"<br>");
document.write("0的余弦值:"+Math.cos(0)+"<br>");
document.write("-1的余弦值:"+Math.cos(-1)+"<br>");
document.write("1的反余弦值的余弦值:"+Math.cos(Math.acos(1))+"<br>");
document.write("1的正切值:"+Math.tan(1)+"<br>");
document.write("0的正切值:"+Math.tan(0)+"<br>");
document.write("-1的正切值:"+Math.tan(-1)+"<br>");
document.write("1的反正切值的正切值:"+Math.tan(Math.atan(1))+"<br>");
document.write("3和5中的最大数:"+Math.max(3,5)+"<br>");
document.write("3和5中的最小数:"+Math.min(3,5)+"<br>");
document.write("-3和5中的最大数:"+Math.max(-3,5)+"<br>");
document.write("-3和5中的最小数:"+Math.min(-3,5)+"<br>");
document.write("3.5和3.4中的最大数:"+Math.max(3.5,3.4)+"<br>");
document.write("3.5和3.4中的最小数:"+Math.min(3.5,3.4));
document.write("对7.5进行四舍五入:"+Math.round(7.5)+"<br>");
document.write("对7.3进行四舍五入:"+Math.round(7.3)+"<br>");
document.write("对-7.8进行四舍五入:"+Math.round(-7.8)+"<br>");
document.write("对-7.3进行四舍五入:"+Math.round(-7.3));
document.write("对7.7进行上舍入:"+Math.ceil(7.7)+"<br>");
document.write("对7.3进行上舍入:"+Math.ceil(7.3)+"<br>");
document.write("对-7.8进行上舍入:"+Math.ceil(-7.8)+"<br>");
document.write("对-7.3进行上舍入:"+Math.ceil(-7.3));
document.write("对7.7进行下舍入:"+Math.floor(7.7)+"<br>");
document.write("对7.3进行下舍入:"+Math.floor(7.3)+"<br>");
document.write("对-7.8进行下舍入:"+Math.floor(-7.8)+"<br>");
document.write("对-7.3进行下舍入:"+Math.floor(-7.3));
//-->
</script>

2. 実行結果

オイラー定数 e の値は (e 属性): 2.718281828459045
2 の自然対数は (LN) 2属性):0.69 31471805599453
10 の自然対数 (LN10 属性): 2.302585092994046 7 の自然対数 (log() メソッド): 1.9459101490553132 0 の自然対数 (log() メソッド): -Infinity
-1 の自然対数 (log ( ) メソッド): NaN
2 の自然対数 (log() メソッド): 0.6931471805599453
底 2 の e の対数値: 1.4426950408889633
底 10 の e の対数値: 0.43429448190325 18
0.7071 0678118654761 広場.41421356237309512 のルート: 1.4142135623730951 4 の平方根: 2 5 の平方根: 2.23606797749979 10 の平方根: 3.1622776601683795 2 の絶対値: 2 0 の絶対値: 0
2:2の絶対値
2.7の絶対値:2.7
-2.7の絶対値: 2.71のサイン: 0.8414709848078965
0のサイン: 0
-1のサイン: -0.8414709848078965
1の逆正弦: 1の余弦
1: 0.54030230586 81398
0 のコサイン: 1
-1 のコサイン: 0.5403023058681398 1 のコサインの逆余弦: 1 1 のタンジェント: 1.5574077246549023 0 のタンジェント: 0 のタンジェント
-1: -1.5574077246549023
1 の正接逆正接: 0.9999999999999999
3 と 5 の間の最大の数: 5
3 と 5 の間の最小の数: 3
- 3 と 5 の間の最大の数: 5
- 3 と 5 の間の最小の数: -3
最大3.5 と 3.4 の間の数値: 3.5
3.5 と 3.4 の間の最小の数値: 3.4
7.5 を四捨五入: 8
四捨五入 7.3: 7
四捨五入 -7.8: -8
四捨五入 -7.3 :-7 四捨五入 7.7: 8
四捨五入 7.3: 8
四捨五入 -7.8: -7
四捨五入 -7.3: -7 四捨五入 7.7: 7
四捨五入 7.3: 7
四捨五入 -7.8: -8
四捨五入 -7.3: -8


私はあなたを信じますこの記事の事例を読んでその方法をマスターした方は、php 中国語 Web サイトの他の関連記事にも注目してください。

推奨読書:


Webstorm を使用して Nodejs 環境と npm を構成する方法

Node.js サンドボックス環境の使用方法

以上がJS で一般的に使用される数学関数は何ですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。