Android 中使用的数学运算
2015-08-10 10:26
483 查看
java.lang.Object
↳ java.lang.Math
类常用的常量和方法:
Math.E记录e的常量
Math.PI 记录的圆周率
Math.IEEEremainder 求余
Math.abs 求绝对值
Math.acos 反余弦函数
Math.asin 反正弦函数
Math.atan 反正切函
Math.atan2 商的反正切函数
Math.sin 正弦函数
Math.cos 余弦函数
Math.tan 正切函数数
Math.cbrt
Math.ceil 得到不小于某数的最大整数
Math.cosh 返回最近的双参数的双曲余弦近似。
Math.exp 求e的任意次方
static double expm1(double d) 返回最接近e d - 1的任意次方近似。
Math.floor 得到不大于某数的最大整数
例如:Math.floor(12.7) =12.0
Math.ceil(12.7) =13.0
ceil()是天花板,即向上取整。floor是地板,向下取整。round是四舍五入。
Math.hypot(double x, double y) 返回x2 + y2)的平方根
Math.log 自然对数
Math.max 求两数中最大
Math.min 求两数中最小
Math.pow 求某数的任意次方, 抛出ArithmeticException处理溢出异常
Math.random 返回0.0,1.0之间的一个随机数
Math.rint 求距离某数最近的整数(可能比某数大,也可能比它小)
Math.round 同上,返回int型或者long型(上一个函数返回double型
Math. signum(double d) 返回参数的符号函数。
Math. ulp 返回参数的ulp(单位最后)。
Math.toDegrees 弧度转化为角度 Math.toRadians 角度转化为弧度
Math.round 同上,返回int型或者long型(上一个函数返回double型)
Math.log10 以10为底的对数
Math.log 自然对数
Math.random 返回0,1之间的一个随机数
java.math.BigInteger(大整数):
BigInteger bi1=new BigInteger(“1234567890123456890”);
BigInteger bi2=BigInteger.valueOf(123L);
bi1=bi1.add(bi2);//b1+b2
bi1=bi1.multiply(bi2);//b1*b2
bi1=bi1.subtract(bi2);//b1-b2
bi1=bi1.divide(bi2);// b1/b2
java.math.BigDecimal(大浮点数):
BigDecimal bd = new BigDecimal(“3.1415926”);
bd = bd.setScale(2,BigDecimal.ROUND_DOWN);//取3.1415926小数点后面二位
↳ java.lang.Math
类常用的常量和方法:
Math.E记录e的常量
Math.PI 记录的圆周率
Math.IEEEremainder 求余
Math.abs 求绝对值
Math.acos 反余弦函数
Math.asin 反正弦函数
Math.atan 反正切函
Math.atan2 商的反正切函数
Math.sin 正弦函数
Math.cos 余弦函数
Math.tan 正切函数数
Math.cbrt
Math.ceil 得到不小于某数的最大整数
Math.cosh 返回最近的双参数的双曲余弦近似。
Math.exp 求e的任意次方
static double expm1(double d) 返回最接近e d - 1的任意次方近似。
Math.floor 得到不大于某数的最大整数
例如:Math.floor(12.7) =12.0
Math.ceil(12.7) =13.0
ceil()是天花板,即向上取整。floor是地板,向下取整。round是四舍五入。
Math.hypot(double x, double y) 返回x2 + y2)的平方根
Math.log 自然对数
Math.max 求两数中最大
Math.min 求两数中最小
Math.pow 求某数的任意次方, 抛出ArithmeticException处理溢出异常
Math.random 返回0.0,1.0之间的一个随机数
Math.rint 求距离某数最近的整数(可能比某数大,也可能比它小)
Math.round 同上,返回int型或者long型(上一个函数返回double型
Math. signum(double d) 返回参数的符号函数。
Math. ulp 返回参数的ulp(单位最后)。
Math.toDegrees 弧度转化为角度 Math.toRadians 角度转化为弧度
Math.round 同上,返回int型或者long型(上一个函数返回double型)
Math.log10 以10为底的对数
Math.log 自然对数
Math.random 返回0,1之间的一个随机数
java.math.BigInteger(大整数):
BigInteger bi1=new BigInteger(“1234567890123456890”);
BigInteger bi2=BigInteger.valueOf(123L);
bi1=bi1.add(bi2);//b1+b2
bi1=bi1.multiply(bi2);//b1*b2
bi1=bi1.subtract(bi2);//b1-b2
bi1=bi1.divide(bi2);// b1/b2
java.math.BigDecimal(大浮点数):
BigDecimal bd = new BigDecimal(“3.1415926”);
bd = bd.setScale(2,BigDecimal.ROUND_DOWN);//取3.1415926小数点后面二位
相关文章推荐
- SSH框架实现返回json数据,并使用android app进行访问
- Android 不同app之间调用activity,通过action实现
- this android sdk requires an e adt to the latest version
- android之Fragment(官网资料翻译)
- kotlin 和java 混编
- 使用TextInputLayout创建一个登陆界面(转自google官网)
- Android新特性介绍,ConstraintLayout完全解析
- Java环境变量的配置以及Android应用签名的生成-------------cmd退回到根目录
- Error running app: This version of Android Studio is incompatible with Gradle Plugin used.Try disabl
- This Android SDK requires Android Developer Toolkit version 20.0.0 or above
- 破解某APP登录协议并编写批量发包工具
- 把流转换成string
- 把流转换成String
- 打造高逼格个人中心效果
- Android开发listview选中高亮简单实现代码分享
- Android Handler 异步消息处理机制的妙用 创建强大的图片加载类
- Android studio 安装中遇到一些问题的解决办法,分享一下
- android:layout_weight的理解
- android两种圆形进度条
- facebook的Android调试工具Stetho介绍