BigInteger valueOf() Method in Java Last Updated : 29 Nov, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The java.math.BigInteger.valueOf(long value) method returns a BigInteger whose value is equal to value of long passed as parameter. This method is static method so It is not necessary to create object of BigInteger class to use this method.we can call this function by BigInteger.valueOf(long value) code. Syntax: public static BigInteger valueOf(long val) Parameter: This method accepts a single parameter value which is the value of the BigInteger to be created. Return Value: This method returns the BigInteger whose value is equal to value of long passed as parameter. Below programs illustrate valueOf(long value ) method of BigInteger class: Example 1: To apply valueOf() without creating BigInteger Object. Java // Java program to demonstrate valueOf() method of BigInteger import java.math.BigInteger; public class GFG { public static void main(String[] args) { // Creating 2 BigInteger objects BigInteger b1, b2; // apply valueOf() b1 = BigInteger.valueOf(456782765); b2 = BigInteger.valueOf(12345543); // print result System.out.println("Value of BigInteger b1: " + b1); System.out.println("Value of BigInteger b2: " + b2); } } Output: Value of BigInteger b1: 456782765 Value of BigInteger b2: 12345543 Example 2: Apply valueOf() by creating BigInteger object. Java // Java program to demonstrate valueOf() method of BigInteger import java.math.BigInteger; public class GFG { public static void main(String[] args) { // Creating BigInteger objects BigInteger b1, b2, b3; // create bigInteger with some value b1 = new BigInteger("532721"); // apply valueOf() b2 = b1.valueOf(234567898); b3 = b2.valueOf(98765432); // print result System.out.println("Value of BigInteger 1: " + b2); System.out.println("Value of BigInteger 2: " + b3); } } Output: Value of BigInteger 1: 234567898 Value of BigInteger 2: 98765432 Reference: https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#valueOf(long) Comment More infoAdvertise with us Next Article BigInteger valueOf() 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 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 BigInteger xor() Method in Java Prerequisite: BigInteger Basics The xor(BigInteger val) method returns bitwise-XOR of two bigIntegers. This method returns a negative BigInteger if and only if exactly one of the current bigInteger and the bigInteger passed in parameter id negative. The xor() method of BigInteger class apply bitwise 2 min read BigInteger pow() Method in Java The java.math.BigInteger.pow(int exponent) method is used to calculate a BigInteger raise to the power of some other number passed as exponent whose value is equal to (this)exponent. This method performs operation upon the current BigInteger by which this method is called and exponent passed as para 2 min read BigInteger not() Method in Java The java.math.BigInteger.not() method is used to find the bitwise-NOT of a BigInteger. This method returns a negative value if and only if this BigInteger is non-negative. The BigInteger.not() method apply bitwise Not operation upon the current bigInteger. Syntax: public BigInteger not() Parameters: 1 min read BigInteger setBit() Method in Java The java.math.BigInteger.setbit(index) method returns a Big-integer whose value is equivalent to this Big-integer with the designated bit set. The method computes (this | (1<<n)). The bit at index n of binary representation of Big-integer will be set means converted to 1. Syntax: public BigInt 2 min read Like