Java一些数学函数的使用

  1. sin(radians) 返回以弧度为单位的角度的三角正弦函数值
  2. cos(radians) 返回以弧度为单位的角度的三角余弦函数值
  3. tan(radians) 返回以弧度为单位的角度的三角正切函数值
  4. toRadians(degree) 将以度为单位的角度值转换为以弧度表示
  5. toDegrees(radians) 将以弧度为单位的角度值转换为以度表示
  6. asin(a) 返回以弧度为单位的角度的反三角正弦函数值
  7. acos(a) 返回以弧度为单位的角度的反三角余弦函数值
  8. atan(a) 返回以弧度为单位的角度的反三角正切函数值 

Math 类还提供了两 个很有用的 double 型常量,PI ( TT ) 和 E (自然对数的底)。可以在任意程序中用Math.PI 和 Math.E 的形式来使用这两个常量。

Math.toDegrees(Math.PI / 2) 返回 90.0

Math.toRadians(30)返回 0.5236 (n/6)

Math.sin(0) returns 0.0

Math.sin(Math.toRadians(270)) 返回-1.0

Math.sin(Math.PI / 6) 返回 0.S

Math.sin(Math.PI / 2)返回 1.0

Math.cos(0) 返回 1.0

Math.cos(Math.PI / 6) 返回 0.866

Math.cos(Math.PI / 2) 返回 0

Math.asin(0.5)返回0. S23S98333 (π/6)

Math.acos(0.5) 返回 1.0472 (π/3)

Math.atan(1.0) 返回 0.78S398 (π/4)

指数函数:

取整函数:

Math.ceil(2.1) 返回3.0

Math.ceil(2.0) 返回2.0

Math.ceil(-2.0)返回 -2.0

Math.ceil(-2.1) 返回-2.0

Math.floor(2.1) 返回2.0

Math.floor(2.0) 返回2.0

Math.floor(-2.0) 返回-2.0

Math.floor(-2.1) 返回-3.0

Math.rint(2.1)返回 2.0

Math.rint(-2.0) 返回-2.0

Math.rint(-2.1) 返回-2.0

Math.rint(2.5) 返回2.0

Math.rint(4.5) 返回4.0

Math.rint(-2.5) 返回-2.0

Math.round(2.6f) 返回3 // Returns int

Math.round(2.0) 返回2 // Returns long

Math.round(-2.0f) 返回-2 // Returns int

Math.round(-2.6) 返回-3 // Returns long

Math.round(-2.4) 返回-2 // Returns long


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值