BigDecimal toBigInteger() Method in Java Last Updated : 09 Nov, 2021 Comments Improve Suggest changes Like Article Like Report The java.math.BigDecimal.toBigInteger() is an inbuilt method in java that converts this BigDecimal to a BigInteger. This conversion is analogous to the narrowing primitive conversion from double to long. Any fractional part of this BigDecimal will be discarded. This conversion can lose information about the precision of the BigDecimal value. Note: If an exception is thrown in the conversion inexact (in other words if a nonzero fractional part is discarded), use the toBigIntegerExact() method. Syntax: public BigInteger toBigInteger() Parameters: This method does not accepts any parameters.Return value: This method returns the value of BigDecimal object converted to a BigInteger. Examples: Input: (BigDecimal) 123.321 Output: (BigInteger) 123 Input: (BigDecimal) 123.001 Output: (BigInteger) 123 Below programs illustrate the working of the above-mentioned method: Program 1: Java // Program to demonstrate toBigInteger() method of BigDecimal import java.math.*; public class GFG { public static void main(String[] args) { // Assigning the BigDecimal b BigDecimal b = new BigDecimal("123.321"); // Assigning the BigInteger value of BigDecimal b to BigInteger i BigInteger i = b.toBigInteger(); // Print i value System.out.println("BigInteger value of " + b + " is " + i); } } Output: BigInteger value of 123.321 is 123 Program 2: Java // Program to demonstrate toBigInteger() method of BigDecimal import java.math.*; public class GFG { public static void main(String[] args) { // Assigning the BigDecimal b BigDecimal b = new BigDecimal("123.001"); // Assigning the BigInteger value of BigDecimal b to BigInteger i BigInteger i = b.toBigInteger(); // Printing i value System.out.println("BigInteger value of " + b + " is " + i); } } Output: BigInteger value of 123.001 is 123 Reference: https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html#toBigInteger() Comment More infoAdvertise with us Next Article BigDecimal toBigInteger() Method in Java T Twinkl Bajaj Follow Improve Article Tags : Misc Java Java-Functions java-math Java-BigDecimal Java-math-package +2 More Practice Tags : JavaMisc Similar Reads BigDecimal toBigIntegerExact() Method in Java The java.math.BigDecimal.toBigIntegerExact() is an inbuilt method in java that converts this BigDecimal to a BigInteger, checking for lost information. An exception is thrown if this BigDecimal has a nonzero fractional part. Syntax: public BigInteger toBigIntegerExact() Parameters: The method does n 2 min read BigDecimal min() Method in Java The java.math.BigDecimal.min(BigDecimal val) method in Java is used to compare two BigDecimal values and return the minimum of the two. Syntax: public BigDecimal min(BigDecimal val) Parameters: The function accepts a BigDecimal object val as parameter whose value is compared with that of this BigDec 2 min read BigDecimal signum() Method in Java The java.math.BigDecimal.signum() is an inbuilt method in Java that returns the signum function of this BigDecimal. The sign function or signum function is an odd mathematical function that extracts the sign of a real number. In mathematical expressions, the sign function is often represented as sgn 2 min read BigDecimal stripTrailingZeros() Method in Java The java.math.BigDecimal.stripTrailingZeros() is an inbuilt method in Java that returns a BigDecimal which is numerically equal to this one but with any trailing zeros removed from the representation. So basically the function trims off the trailing zero from the BigDecimal value. Syntax: public Big 2 min read BigDecimal precision() Method in Java The java.math.BigDecimal.precision() method returns the precision of this BigDecimal. The precision refers to the number of digits in the unscaled value. Syntax: public int precision() Parameters: This method does not accept any parameters. Return Value: This method returns an integer which denotes 2 min read BigDecimal multiply() Method in Java The java.math.BigDecimal.multiply(BigDecimal multiplicand) is an inbuilt method in java that returns a BigDecimal whose value is (this à multiplicand), and whose scale is (this.scale() + multiplicand.scale()). Syntax: public BigDecimal multiply(BigDecimal multiplicand) Parameters: This method accept 3 min read BigDecimal ulp() Method in Java The java.math.BigDecimal.ulp() is an inbuilt method in Java that returns the size of an ulp(unit in the last place) of this BigDecimal. An ulp of a nonzero BigDecimal value is defined as the positive distance between this value and the BigDecimal value next larger in magnitude with the same number o 2 min read BigDecimal valueOf() Method in Java java.math.BigDecimal.valueOf(long val) is an inbuilt method in Java that translates a long value into a BigDecimal value with a scale of zero. It allows us, the reuse of frequently used BigDecimal values and hence this "static factory method" is provided in preference to a (long) constructor. Packag 3 min read BigDecimal shortValueExact() Method in Java The java.math.BigDecimal.shortValueExact() is an inbuilt method in java that converts this BigDecimal to a short, checking for lost information. If this BigDecimal has a nonzero fractional part or is out of the possible range for a short result then an ArithmeticException is thrown. Syntax: public s 2 min read BigDecimal plus() method in Java The java.math.BigDecimal.plus() is an inbuilt method in java that returns a BigDecimal whose value is (+this), and whose scale is this.scale(). This method, which simply returns this BigDecimal is included for symmetry with the unary minus method negate().Syntax: public BigDecimal plus()Parameters: 3 min read Like