How does the getChar function work?

Viewed 198
private static char[] getChars(int i) {
    char buf[] = new char[32];
    int q;
    for (int j = 31; j >= 0; j--) {
         q = (i * 52429) >>> (19);
         int r = i - ((q << 3) + (q << 1));
         buf[j] = (char) (r + '0');
         i = q;
         if (i == 0)
             break;
    }

 return buf;
}

The above code is based on a part of java.lang.Integer.getChars(int). How did the developers come up with this "magic" number 52429. What is the math behind it? After 81920 as input this function doesn't work. does this magic number only work for a certain range of inputs, if so why?

1 Answers
Related