Parse and format to arbitrary radix <= Character.MAX_RADIX in Java



Let us set a radix here as.

// radix int r = 32;

Include the radix here as a BigInteger constructor.

BigInteger one = new BigInteger("vv", r);

Now get its string representation −

String strResult = one.toString(radix);

The following is an example −

Example

 Live Demo

import java.math.*; public class Demo { public static void main(String[] args) { // radix int r = 32; BigInteger one = new BigInteger("vv", r); String strResult = one.toString(r); System.out.println(strResult); } }

Output

vv
Updated on: 2019-07-30T22:30:24+05:30

299 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements