java - Whats going on behind the scenes with method - public static long parseLong(String s,int radix) -


i need generate consistent unique long based on name of package. instead of using "convert string long" in eclipse think can achieve same task @ run time using method public static long parselong(string s,int radix) ?

i think need use -
long.parselong("hazelnut", 36) returns 1356099454469l

which got question - how convert string long in java?

why need set radix 36 when converting string contains characters ?

well, you're treat number in base 36. example, string "012" mean 2 + 1 * 36 + 0 * 362. when run out of digits, go letters - "abc" mean 12from 'c' + 11from 'b' * 36 + 10from 'a' * 362.

if understand how hex works, it's same except using characters in latin alphabet.

it'll fail not in 0-9, a-z, a-z though - , it'll fail reasonably long strings; long works 263 you'll past reasonably in base 36. "hazelnut12345" fails, example. oh, , case-insensitive, value "foo" same "foo" - fail uniqueness requirement?

fundamentally you've got 264 long values play with, unless package names pretty restricted you're not going work out unique mapping.


Comments

Popular posts from this blog

How can I edit my VIM config so that Vim treats ".ejs" files the same as it currently treats my html files? -

Python __call__ special method practical example -