Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the significance of radix in Character.fordigit() in Java?

Tags:

java

Could someone please help me understand the significance of radix in the Character.forDigit(int digit, int radix) method?

like image 673
paulophoenix Avatar asked Oct 11 '25 19:10

paulophoenix


1 Answers

Choosing a suitable radix lets you produce "digits" that are not decimal digits - for example, if you pass 16 for the radix, you can produce characters for digits ten through fifteen, because counting in hex uses sixteen digits - 0 through 9, followed by A through F:

char ten = Character.forDigit(10, 16); // returns 'a'

Demo.

like image 58
Sergey Kalinichenko Avatar answered Oct 14 '25 10:10

Sergey Kalinichenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!