how to initialize bigdecimal in java
BigDecimal num = new BigDecimal(123);
how to initialize bigdecimal in java
BigDecimal num = new BigDecimal(123);
java biginteger
The java.math.BigInteger.compareTo(BigInteger value) method
Compares this BigInteger with the BigInteger passed as the parameter.
________________________________________
import java.math.BigInteger;
public class GFG {
public static void main(String[] args)
{
// Creating 2 BigInteger objects
BigInteger b1, b2;
b1 = new BigInteger("321456");
b2 = new BigInteger("321456");
// apply compareTo() method
int comparevalue = b1.compareTo(b2);
// print result
if (comparevalue == 0) {
System.out.println("BigInteger1 "
+ b1 + " and BigInteger2 "
+ b2 + " are equal");
}
else if (comparevalue == 1) {
System.out.println("BigInteger1 " + b1 + "
is greater than BigInteger2 " + b2);
}
else {
System.out.println("BigInteger1 " + b1 + "
is lesser than BigInteger2 " + b2);
}
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us