Parse decimal string to create BigInteger in Java


To parse the decimal string to create BigInteger, just set the decimal string in the BigInteger.

Here is our BigInteger.

BigInteger one;
String decStr = "687879";
one = new BigInteger(decStr);

Let us see another example −

Example

 Live Demo

import java.math.*;
public class Demo {
   public static void main(String[] args) {
      BigInteger one, two;
      String decStr = "4373427";
      one = new BigInteger("250");
      two = new BigInteger(decStr);
      System.out.println("Result (BigInteger) : " +one);
      System.out.println("Result (Parsing Decimal String) : " +two);
   }
}

Output

Result (BigInteger) : 250
Result (Parsing Decimal String) : 4373427

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 29-Jun-2020

210 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements