1. private void mathMethod(){
    2. // Math.sqrt()//计算平方根 Math.cbrt()//计算立方根 Math.hypot(x,y)//计算 (x的平方+y的平方)的平方根
    3. Log.d("TAG","Math.sqrt(16)----:"+Math.sqrt(16));//4.0
    4. Log.d("TAG","Math.cbrt(8)----:"+Math.cbrt(8));//2.0
    5. Log.d("TAG","Math.hypot(3,4)----:"+Math.hypot(3,4));//5.0
    6. // Math.pow(a,b)//计算a的b次方 Math.exp(x)//计算e^x的值
    7. Log.d("TAG","------------------------------------------");
    8. Log.d("TAG","Math.pow(3,2)----:"+Math.pow(3,2));//9.0
    9. Log.d("TAG","Math.exp(3)----:"+Math.exp(3));//20.085536923187668
    10. //Math.max();//计算最大值 Math.min();//计算最小值
    11. Log.d("TAG","------------------------------------------");
    12. Log.d("TAG","Math.max(2.3,4.5)----:"+Math.max(7,15));//15
    13. Log.d("TAG","Math.min(2.3,4.5)----:"+Math.min(2.3,4.5));//2.3
    14. //Math.abs求绝对值
    15. Log.d("TAG","------------------------------------------");
    16. Log.d("TAG","Math.abs(-10.4)----:"+Math.abs(-10.4));//10.4
    17. Log.d("TAG","Math.abs(10.1)----:"+Math.abs(10.1));//10.1
    18. //Math.ceil天花板的意思,就是返回大的值
    19. Log.d("TAG","------------------------------------------");
    20. Log.d("TAG","Math.ceil(-10.1)----:"+Math.ceil(-10.1));//-10.0
    21. Log.d("TAG","Math.ceil(10.7)----:"+Math.ceil(10.7));//11.0
    22. Log.d("TAG","Math.ceil(-0.7)----:"+Math.ceil(-0.7));//-0.0
    23. Log.d("TAG","Math.ceil(0.0)----:"+Math.ceil(0.0));//0.0
    24. Log.d("TAG","Math.ceil(-0.0)----:"+Math.ceil(-0.0));//-0.0
    25. Log.d("TAG","Math.ceil(-1.7)----:"+Math.ceil(-1.7));//-1.0
    26. //Math.floor地板的意思,就是返回小的值
    27. Log.d("TAG","------------------------------------------");
    28. Log.d("TAG","Math.floor(-10.1)----:"+Math.floor(-10.1));//-11.0
    29. Log.d("TAG","Math.floor(10.7)----:"+Math.floor(10.7));//10.0
    30. Log.d("TAG","Math.floor(-0.7)----:"+Math.floor(-0.7));//-1.0
    31. Log.d("TAG","Math.floor(0.0)----:"+Math.floor(0.0));//0.0
    32. Log.d("TAG","Math.floor(-0.0)----:"+Math.floor(-0.0));//-0.0
    33. //Math.random 取得一个大于或者等于0.0小于不等于1.0的随机数[0,1)
    34. Log.d("TAG","------------------------------------------");
    35. Log.d("TAG","Math.random()----:"+Math.random());//输出[0,1)间的随机数 0.8979626325354049
    36. Log.d("TAG","Math.random()*100----:"+Math.random()*100);//输出[0,100)间的随机数 32.783762836248144
    37. // Math.rint 四舍五入 返回double值
    38. Log.d("TAG","------------------------------------------");
    39. Log.d("TAG","Math.rint(10.1)----:"+Math.rint(10.1));//10.0
    40. Log.d("TAG","Math.rint(10.7)----:"+Math.rint(10.7));//11.0
    41. Log.d("TAG","Math.rint(-10.5)----:"+Math.rint(-10.5));//-10.0
    42. Log.d("TAG","Math.rint(-10.51)----:"+Math.rint(-10.51));//-11.0
    43. Log.d("TAG","Math.rint(-10.2)----:"+Math.rint(-10.2));//-10.0
    44. Log.d("TAG","Math.rint(9)----:"+Math.rint(9));//9.0
    45. //Math.round 四舍五入 float时返回int值,double时返回long值
    46. Log.d("TAG","------------------------------------------");
    47. Log.d("TAG","Math.round(10.1)----:"+Math.round(10.1));//10
    48. Log.d("TAG","Math.round(10.7)----:"+Math.round(10.7));//11
    49. Log.d("TAG","Math.round(-10.5)----:"+Math.round(-10.5));//-10
    50. Log.d("TAG","Math.round(-10.51)----:"+Math.round(-10.51));//-11
    51. Log.d("TAG","Math.round(-10.2)----:"+Math.round(-10.2));//-10
    52. Log.d("TAG","Math.round(9)----:"+Math.round(9));//9
    53. //Math.nextUp(a) 返回比a大一点点的浮点数
    54. Log.d("TAG","------------------------------------------");
    55. Log.d("TAG","Math.nextUp(1.2)----:"+Math.nextUp(1.2));//1.2000000000000002
    56. //Math.nextDown(a) 返回比a小一点点的浮点数
    57. Log.d("TAG","------------------------------------------");
    58. Log.d("TAG","Math.nextDown(1.2)----:"+Math.nextDown(1.2));//1.1999999999999997
    59. //Math.nextAfter(a,b) 返回(a,b)或(b,a)间与a相邻的浮点数 b可以比a小
    60. Log.d("TAG","------------------------------------------");
    61. Log.d("TAG","Math.nextAfter(1.2, 2.7)----:"+Math.nextAfter(1.2, 2.7));//1.2000000000000002
    62. Log.d("TAG","Math.nextAfter(1.2, -1)----:"+Math.nextAfter(1.2, -1));//1.1999999999999997
    63. }