Math.ceil()

简介: Math.ceil()

Math.ceil()
Math.ceil(x) 的返回值是 x 上舍入最接近的整数:

实例
Math.ceil(6.4); // 返回 7
亲自试一试
Math.floor()
Math.floor(x) 的返回值是 x 下舍入最接近的整数:

实例
Math.floor(2.7); // 返回 2
亲自试一试
Math.sin()
Math.sin(x) 返回角 x(以弧度计)的正弦(介于 -1 与 1 之间的值)。

如果您希望使用角度替代弧度,则需要将角度转换为弧度:

Angle in radians = Angle in degrees x PI / 180.
实例
Math.sin(90 * Math.PI / 180); // 返回 1(90 度的正弦)
亲自试一试
Math.cos()
Math.cos(x) 返回角 x(以弧度计)的余弦(介于 -1 与 1 之间的值)。

如果您希望使用角度替代弧度,则需要将角度转换为弧度:

Angle in radians = Angle in degrees x PI / 180.
实例
Math.cos(0 * Math.PI / 180); // 返回 1(0 度的余弦)

目录
相关文章
|
7月前
Math方法的使用
Math方法的使用
27 0
|
11月前
|
C++
C++ 多种取整函数的使用和区别: ceil() floor() round() trunc() rint() nearbyint()
C++ 多种取整函数的使用和区别: ceil() floor() round() trunc() rint() nearbyint()
139 0
Math.pow()
Math.pow()
51 0
|
JavaScript 前端开发
Math.random();
Math.random();
61 0
4.2、Math数学对象(floor、random、sqrt、pow、abs)
4.2、Math数学对象(floor、random、sqrt、pow、abs)
128 0
|
安全 iOS开发
iOS开发-math.h/ceil/floor/round
https://blog.csdn.net/acmicpc123/article/details/50280097
113 0
iOS开发-math.h/ceil/floor/round
|
算法 机器学习/深度学习
Math
机器学习中的数学基础 微分学 求导数 求偏导数 以上两个通过公式或者使用泰勒公式进行逼近得到的 求f(x)在x0处的导数 根据泰勒公式: f(x) = f(x0) + f'(x0)(x - x0) + f''(x0)(x - x0)^2/2! + f'''(x0)(x - x0)^3/3! + .
895 0
Math.round(11.5) 等于多少?Math.round(-11.5)等于多少?
Math.round(11.5)的返回值是12,Math.round(-11.5)的返回值是-11。四舍五入的原理是在参数上加0.5然后进行下取整。
1566 0