您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 黔东南分类信息网,免费分类信息发布

JavaScript常用数学函数代码汇总

2024/4/14 17:21:26发布25次查看
这次给大家带来javascript常用数学函数代码汇总,javascript常用数学函数使用的注意事项有哪些,下面就是实战案例,一起来看一下。
一、代码
<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>
二、运行结果
欧拉常数e的值为(e属性):2.718281828459045
2的自然对数为(ln2属性):0.6931471805599453
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.4342944819032518
0.70710678118654761.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.5403023058681398
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
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
vue在自定义组件中使用v-model步骤详解
在vue组件中传递数据步骤详解
以上就是javascript常用数学函数代码汇总的详细内容。
黔东南分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录