Digit () in CharacterData00.class java
Can someone help me understand exactly how (the logic, in particular the computation of a variable value) in the method below (derived from the Java 7 SDK java.lang.CharacterData00.class) is the digit value defined for a given character. I ended up here trying to understand the Long.valueOf (String) method. Are properties obtained using getProperties java specific? I didn't find any details on the internet. Any links or comments would be appreciated. Thank!
int digit(int ch, int radix) {
int value = -1;
if (radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX) {
int val = getProperties(ch);
int kind = val & 0x1F;
if (kind == Character.DECIMAL_DIGIT_NUMBER) {
value = ch + ((val & 0x3E0) >> 5) & 0x1F;
}
else if ((val & 0xC00) == 0x00000C00) {
// Java supradecimal digit
value = (ch + ((val & 0x3E0) >> 5) & 0x1F) + 10;
}
}
return (value < radix) ? value : -1;
}
source to share
I would think getProperties reads Unicode categories for the code point. They will be listed in the Unicode database , which changes when Unicode is updated with new code points. Java 7 supports Unicode 6.
It then uses a mask to check if the code point is in the Nd category.
I'm not following the rest of the logic, but I would suggest that the digits of the code point values ββare assigned to the following pattern. You will undoubtedly find more in the Unicode standard .
source to share