Math Random BigInteger BigDecimal
来源:互联网 发布:淘宝怎么转人工服务 编辑:程序博客网 时间:2024/05/23 19:20
Math类
math提供了系列的数学操作方法。所有的方法都是以静态的形式出现的
1, math.PI //取π
2.math.max(1,2); //取大值
3.math.round(89.9876); //四舍五入
package org.lxh.mathdemo;public class MathDemo {public static void main(String[] args) {System.out.println("PI = " + Math.PI);System.out.println(Math.max(1, 2));System.out.println(Math.round(89.9876));// 四舍五入}}
Random类(可以取得一系列的指定范围的随机数)
package org.lxh.randomdemo;import java.util.Random;public class RandomDemo {public static void main(String[] args) {Random r = new Random();for (int i = 0; i < 10; i++) {System.out.print(r.nextInt(100) + "、");}}}
BigInteger类(表示大的整型数据)
package org.lxh.largenumberdemo;import java.math.BigInteger;public class BigIntegerDemo {public static void main(String[] args) {String num1 = "9999999999999999999999999999999999";String num2 = "9999999999999999999999999999999998";BigInteger big1 = new BigInteger(num1); // 实例化BigInteger对象BigInteger big2 = new BigInteger(num2); // 实例化BigInteger对象System.out.println("加法操作:" + big1.add(big2));System.out.println("减法操作:" + big1.subtract(big2));System.out.println("乘法操作:" + big1.multiply(big2));System.out.println("除法操作:" + big1.divide(big2));BigInteger result[] = big1.divideAndRemainder(big2);// 进行触发操作,有余数System.out.println("相除之后的商是:" + result[0]);System.out.println("相除之后的余数是:" + result[1]);}}
BigDecimal类主要是小数的大数计算,而且最重要的是可以精确到指定的四舍五入位数
如果想要进行四舍五入的操作,则必须依靠以下的方法:
public BigDecimal divide(BigDecimal divistor,int scale,int roundingMode)
|-scale:表示四舍五入的位数
- Math Random BigInteger BigDecimal
- Java常用类库--Math、Random、NumberFormat、DecimalFormat、BigInteger、BigDecimal
- 正则表达式,Math,Random,system,BigInteger,BigDecimal,Data/DataFormat,Calender
- day14(正则表达式,Math,Random,System,BigInteger,BigDecimal,Date等)
- 类:BigDecimal,BigInteger,Math,System
- 简单常用类:Math 、Random、System、Integer、Character、BigInteger、BigDecimal等
- JavaSE----API之常用类(Math、Random、System、BigInteger和BigDecimal、Date和DateFormat、Calendar)
- 14 API-常用类(正则表达式(Pattern,Matcher),Math,Random,System,BigInteger,BigDecimal,Date/DateFormat,Calendar)
- 常见对象_Regex、Math、Random、System、BigInteger、BigDecimal、Date/DateFormat、Calendar总结
- JAVA基础复习十四-Math、Random、System、BigInteger、BigDecimal、Date、SimpleDateFormat类
- 14. 正则表达式和常见类 (Math、Random、System、BigInteger、BigDecimal、Date_DateFormat、Calendar)
- java.math.BigDecimal 和java.math.BigInteger
- Java.math.BigInteger/Java.math.BigDecimal
- java.math包中的BigInteger和BigDecimal
- Java常用类-Math、BigInteger、BigDecimal
- 11. JAVA常用类库 Part 3 (Math类、Random类、NumberFormat类、BigInteger类和BigDecimal类) ----- 学习笔记
- Java中正则表达式和常用的Math、Random、System、BigInteger、BigDecimal、Date/DateFormat、Calendar类的使用
- Java基础学习笔记14——(正则表达式,Math,Random,System,BigInteger,BigDecimal,Date/DateFormat,Calendar)
- 使用 udev 高效、动态地管理 Linux 设备文件
- FineReport 7.0正式版发布——B/S设计器引领报表行业趋势
- Calendar的add()方法介绍
- Oracle 中使用 fetch bulk collect into 批量效率的读取
- 高效率随机删除数据(不重复)
- Math Random BigInteger BigDecimal
- Android自学笔记:分析onXXX事件监听器中的两个参数position和id
- Mac svn命令 linux同样适用
- ORACLE内部函数大全以及与SQLSERVER的区别
- 获得Android系统外置SD卡的路径
- 一例undefined reference 处理方法
- servlet中怎么获得web的相对路径
- ie6 a包span的问题
- com.ibatis.sqlmap.client.SqlMapExceptionThere is no statement named XIU_ITEM_INFO.ibatorgenerated_in