Javatpoint Logo
Javatpoint Logo

Vigesimal in Java

In Java, the Vigesimal is a number system having a base of 20. Like Duodecimal numbers, we can use predefined or user-defined methods to either find the equivalent vigesimal number of binary, octal, decimal and hexadecimal numbers or to find the equivalent other base numbers of the given vigesimal number.

These are some examples of vigesimal numbers.

  1. The vigesimal number(AF)20 is equal to the binary number (11010111)2.
  2. The vigesimal number (C2)20 is equal to the octal number (362)8.
  3. The vigesimal number (I2)20 is equal to the decimal number (362)10.
  4. The vigesimal number (44DBI)20 is equal to the hexadecimal number (A563E)16.
  5. The vigesimal number (36BJCE)20 is equal to the hexa-trigesimal number (A563E)32.

Steps to find vigesimal number

These are the following steps to find the vigesimal number of the given hexadecimal number of any base:

  1. Take a hexadecimal number from the user as an input.
  2. Create a user-defined method to convert it into decimal.
  3. We also create a user-defined function that takes the decimal number and converts it into vigesimal
  4. Return the vigesimal number.

Let's implement the logic to convert a hexadecimal number into a vigesimal number:

VigesimalNumber.java

Output:

Vigesimal in Java

In order to convert other base numbers except for hexadecimal, we have to create other user-defined methods like the convertToDec() method, which will convert the given number into decimal and return it for calculating the vigesimal number.


Next TopicJava Color Codes





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA