Friday 24 May 2019

Java: Is BigInteger has any limit?


As per Java documentation, BigInteger is an Immutable arbitrary-precision integer. That means, theoretically there is no limit on the size of BigInteger (Practically, the limit depends on the memory of the system).

Example
BigInteger bigIntegr = new BigInteger("111111112222222233333333344444444455555556666667777777888888899999000000");

App.java
package com.sample.app;

import java.io.IOException;
import java.math.BigInteger;

public class App {

 public static void main(String args[]) throws IOException {

  BigInteger bigIntegr = new BigInteger("111111112222222233333333344444444455555556666667777777888888899999000000");
  
  System.out.println("bigIntegr : " + bigIntegr);
  
 }
}

Output
bigIntegr : 111111112222222233333333344444444455555556666667777777888888899999000000


You may like

No comments:

Post a Comment