Answers for "java int bigdecimal"

2

how to initialize bigdecimal in java

BigDecimal num = new BigDecimal(123);
Posted by: Guest on May-21-2021
1

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);
        }
    }
}
Posted by: Guest on August-06-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language