import java.math.BigInteger; public class Main { public static void main(String[] args) { BigInteger n1 = new BigInteger("1000000000000000"); BigInteger n2 = new BigInteger("999999999999999"); BigInteger diff = n1.subtract(n2); System.out.println("n1 - n2 = " + diff); } }
n1 - n2 = 1
import java.math.BigInteger; public class Main { public static void main(String[] args) { BigInteger n1 = new BigInteger("1000000000000000"); BigInteger diff = n1.subtract(n1); System.out.println("n1 - n1 = " + diff); } }
n1 - n1 = 0This method is a part of the java.math package library.