سؤال

I'm not sure I understand what this method does. Can someone explain ? All I know, from what I read, is that "This method returns the numeric value represented by the character in the specified radix." I'm not sure what a radix is and what it represents. According to the description of what is being returned, I assumed this method gets a character and returns the numeric value of it in the ASCII table, but I guesses that's not true ?

هل كانت مفيدة؟

المحلول

Are you familiar with numerical bases?

For example, '3' in base 10 is equal to 3, '101' in base 2 is equal to 5 in base 10, etc.

That's essentially what Character.digit does -- it takes a character, a specified base, and returns the numerical value in base 10.

If you provide it with a value greater then the specified base (for example, Character.digit('3', 2);, it'll just return -1, signifying an invalid value.

نصائح أخرى

The method isDigit is true of the character and the Unicode decimal digit value of the character (or its single-character decomposition) is less than the specified radix. In this case the decimal digit value is returned.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top