BigInteger intValue() Method in Java Last Updated : 07 Oct, 2022 Comments Improve Suggest changes Like Article Like Report The java.math.BigInteger.intValue() converts this BigInteger to an integer value. If the value returned by this function is too big to fit into integer value, then it will return only the low-order 32 bits. Further there is chance that this conversion can lose information about the overall magnitude of the BigInteger value. This method can also return the result with opposite sign. Syntax: public int intValue() Returns: The method returns an int value which represents integer value for this BigInteger. Examples: Input: BigInteger1=32145 Output: 32145 Explanation: BigInteger1.intValue()=32145. Input: BigInteger1=4326516236135 Output: 1484169063 Explanation: BigInteger1.intValue()=1484169063. This BigInteger is too big for intValue so it is returning lower 32 bit. Example 1:Below programs illustrate intValue() method of BigInteger class Java // Java program to demonstrate // intValue() method of BigInteger import java.math.BigInteger; public class GFG { public static void main(String[] args) { // Creating 2 BigInteger objects BigInteger b1, b2; b1 = new BigInteger("32145"); b2 = new BigInteger("7613721"); // apply intValue() method int intValueOfb1 = b1.intValue(); int intValueOfb2 = b2.intValue(); // print intValue System.out.println("intValue of " + b1 + " : " + intValueOfb1); System.out.println("intValue of " + b2 + " : " + intValueOfb2); } } Output:intValue of 32145 : 32145 intValue of 7613721 : 7613721 Example 2: when return integer is too big for int value. Java // Java program to demonstrate // intValue() method of BigInteger import java.math.BigInteger; public class GFG { public static void main(String[] args) { // Creating 2 BigInteger objects BigInteger b1, b2; b1 = new BigInteger("4326516236135"); b2 = new BigInteger("251362466336"); // apply intValue() method int intValueOfb1 = b1.intValue(); int intValueOfb2 = b2.intValue(); // print intValue System.out.println("intValue of " + b1 + " : " + intValueOfb1); System.out.println("intValue of " + b2 + " : " + intValueOfb2); } } Output:intValue of 4326516236135 : 1484169063 intValue of 251362466336 : -2040604128 Reference: BigInteger intValue() Docs Comment More infoAdvertise with us Next Article BigInteger intValue() Method in Java A AmanSingh2210 Follow Improve Article Tags : Java java-basics Java-Functions java-math Java-BigInteger Java-math-package +2 More Practice Tags : JavaJava-BigInteger Similar Reads Integer intValue() Method in Java intValue() of Integer class that is present inside java.lang package is an inbuilt method in java that returns the value of this integer as an int which is inherited from Number Class. The package view is as follows: --> java.lang Package --> Integer Class --> intValue() Method Syntax: publ 3 min read BigInteger floatValue() Method in Java The java.math.BigInteger.floatValue() converts this BigInteger to a float value. If the value returned by this function is too big for a magnitude to represent as a float then it will be converted to Float.NEGATIVE_INFINITY or Float.POSITIVE_INFINITY as appropriate. There is a chance that this conve 2 min read BigDecimal intValue() Method in Java The java.math.BigDecimal.intValue() is an in-built function which converts this BigDecimal to an integer value. This function discards any fractional part of this BigDecimal. If the result of the conversion is too big to be represented as an integer value, the function returns only the lower-order 3 2 min read BigInteger bitCount() Method in Java Prerequisite: BigInteger Basics The java.math.BigInteger.bitCount() method returns number of bits in the two's complement representation of this BigInteger that differ from its sign bit. This method is useful when implementing bit-vector style sets atop BigIntegers.Syntax: public int bitCount() Para 1 min read BigInteger or() method in Java Prerequisite: BigInteger Basics The java.math.BigInteger.or(BigInteger val) method is used to perform bitwise OR of two BigIntegers. One of the BigInteger is passed in parameter and the other on which the function is called. This method returns a negative number if either of the BigIntegers used wit 2 min read Like