BigInteger的加减乘除

import java.math.BigInteger;
import java.util.Arrays;
 
/*
 * public BigInteger add(BigInteger val):加
 * public BigInteger subtract(BigInteger val):减
 * public BigInteger multiply(BigInteger val):乘
 * public BigInteger divide(BigInteger val):除
 * public BigInteger[] divideAndRemainder(BingInteger val):返回商和余数的数组
 */
public class BigIntegerDemo {
	public static void main(String[] args) {
		BigInteger bi1 = new BigInteger("999");
		BigInteger bi2 = new BigInteger("50");
		
		//public BigInteger add(BigInteger val):加
		System.out.println("add:"+bi1.add(bi2));
		
		//public BigInteger subtract(BigInteger val):减
		System.out.println("subtract:"+bi1.subtract(bi2));
		
		//public BigInteger multiply(BigInteger val):乘
		System.out.println("multiply:"+bi1.multiply(bi2));
		
		//public BigInteger divide(BigInteger val):除
		System.out.println("divide:"+bi1.divide(bi2));
		
		//public BigInteger[] divideAndRemainder(BingInteger val):返回商和余数的数组
		BigInteger[] bis = bi1.divideAndRemainder(bi2);
		System.out.println("divideAndRemainder:"+Arrays.toString(bis));
		System.out.println("商:"+bis[0]);
		System.out.println("余数:"+bis[1]);
	}
 
}
 
全部评论

相关推荐

但听说转正率很低,我现在有在实习了,好纠结要不要去
熬夜脱发码农:转正率低归低,但是实习的经历你可以拿着,又不是说秋招不准备了
点赞 评论 收藏
分享
05-26 10:24
门头沟学院 Java
qq乃乃好喝到咩噗茶:其实是对的,线上面试容易被人当野怪刷了
找工作时遇到的神仙HR
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务