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

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -