Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
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
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
Advertisements
