1

As an example, I want to convert:

1j16qd5g0lc

To:

5589146303201280

But currently ‘tonumber’ converts it to:

5.5891463032013e+15

I understand that there is a bit.tonumber function that might work better but that function is not available to me. Could someone implement what I need easily? I am not too familiar Lua.

Thank you! :)

  • Have you attempted implementing it yourself? – abraabra Feb 26 '14 at 22:51
  • I imagine something like the Base36Decode function on http://en.wikipedia.org/wiki/Base_36#C.23_implementation can be converted to Lua but since I am not too familiar with Lua, I can't figure it out. – Bill Shakespeare Feb 26 '14 at 23:01
  • So you need to have the output be a number? Lua numbers cannot be that large, so your only hope is string or a large numbers library (which probably splits a number into several parts using tables). – Oliver Feb 26 '14 at 23:39
  • My final output needs to be a string of the number. Maybe the conversion could possibly be done in chunks? – Bill Shakespeare Feb 27 '14 at 00:45

1 Answers1

2

Try print(string.format("%.0f",tonumber("1j16qd5g0lc",36))).

lhf
  • 70,581
  • 9
  • 108
  • 149