Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

Parse Octal String to Create BigInteger in Java



To parse the octal string to create BigInteger, use the following BigInteger constructor and set the radix as 8 for Octal −

BigInteger(String val, int radix)

This constructor is used to translate the String representation of a BigInteger in the specified radix into a BigInteger.

In the below example, we have set the BigInteger and radix is set as 8.

BigInteger one, two;
one = new BigInteger("12");
two = new BigInteger("4373427", 8);

The following is the complete example −

Example

 Live Demo

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

Output

Result (BigInteger) : 12
Result (Parsing Octal String) : 1177367
Updated on: 2020-06-29T05:48:05+05:30

156 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements