做公司企业网站,wordpress菜单锚点定位,手机网页的视频怎么下载到本地,专业的聊城做网站费用一、应用场景 1. BigInteger 类
目前#xff0c;我们学过最大的是long类型#xff0c;但是#xff0c;在实际开发时候#xff0c;很有可能遇见超出long类型范围的数#xff0c;我们就需要用BigInteger类#xff1b;
① add 加
② subtract 减
③ multiply 乘…一、应用场景 1. BigInteger 类
目前我们学过最大的是long类型但是在实际开发时候很有可能遇见超出long类型范围的数我们就需要用BigInteger类
① add 加
② subtract 减
③ multiply 乘
④ divide 除
public class BigInteger_ {public static void main(String[] args) {BigInteger bigInteger new BigInteger(299999999999999999999999999999999);System.out.println(bigInteger);
// 在对BigInteger类型的数据进行 加减乘除 时不能直接 - * /
// 要使用相应的方法BigInteger bigInteger1 new BigInteger(100);
// 1.加BigInteger add bigInteger.add(bigInteger1);System.out.println(add);
// 2.减BigInteger subtract bigInteger.subtract(bigInteger1);System.out.println(subtract);
// 3.乘BigInteger multiply bigInteger.multiply(bigInteger1);System.out.println(multiply);
// 4.除BigInteger divide bigInteger.divide(bigInteger1);System.out.println(divide);}
}2. BigDecimal 类
目前我们学过精度最高的是double类型但是在实际开发时候很有可能需要精度更高的类型我们就需要用BigDecimal类
public class BigDecimal_ {public static void main(String[] args) {BigDecimal bigDecimal new BigDecimal(2.99999999999999999999999999999999);System.out.println(bigDecimal);
// 在对BigDecimal类型的数据进行 加减乘除 时不能直接 - * /
// 要使用相应的方法BigDecimal bigDecimal1 new BigDecimal(1.63);
// 1.加BigDecimal add bigDecimal.add(bigDecimal1);System.out.println(add);
// 2.减BigDecimal subtract bigDecimal.subtract(bigDecimal1);System.out.println(subtract);
// 3.乘BigDecimal multiply bigDecimal.multiply(bigDecimal1);System.out.println(multiply);
// 4.除BigDecimal divide bigDecimal.divide(bigDecimal1);//可能会抛出异常
// 在调用divide 方法时指定精度即可
// 如果有无限循环小数就会保留 分子 的精度BigDecimal divide1 bigDecimal.divide(bigDecimal1,BigDecimal.ROUND_CEILING);System.out.println(divide1);}
}