user3368814
user3368814

Reputation: 7

Weird Numbers/Characters within code

I've downloaded an open-source program, and found this:

public static final char playerNameXlateTable[] = { '_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '[', ']', '/', '-', ' ' };

    public static String longToPlayerName2(long l) {
        int i = 0;
        char ac[] = new char[99];
        while (l != 0L) {
            long l1 = l;
            l /= 37L;
            ac[11 - i++] = playerNameXlateTable[(int) (l1 - l * 37L)];
        }
        return new String(ac, 12 - i, i);
    }

And I tried figuring out what the 37L was for. I first thought it might be Hex, but I found that Hex doesn't have any 'L's.

Does someone have a clue what type of that is? And what it converts to in actual number?

Thank you very much!

Upvotes: 0

Views: 86

Answers (3)

Miguel Dickson
Miguel Dickson

Reputation: 208

A capital L simply designates that the number is a long literal. The letter "l" can also be used, but it's sensibly not recommended since it's hard to tell from a "1". Similarly, the "f" letter after a number designates a float literal.

See docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

Upvotes: 3

endriu_l
endriu_l

Reputation: 1659

37L means 37 in long type. This is done in order to keep type of the multiplication

Upvotes: 0

Arrem
Arrem

Reputation: 1023

Well, L or l just converts it to long.

Upvotes: 0

Related Questions