Convert number to base36


Ramon de Wit
 

Hey group,

 

 

I have to convert a number to a base36 string. Ideally I have to do it within Magic.

 

Has anyone an example for this maybe?

 

 

Thanks,

 

 

Ramon

 


sherman levine
 

You should be able to loop thru something like this

Update DecNum to starting number

Loop
    Digit = DecNum mod 36.    Add digit to Base36String
    DecNum=fix (DecNum/36,12,0)
Until Decnum=0

Sherm

On 4/6/2021 10:06 AM, Ramon de Wit wrote:

Hey group,

 

 

I have to convert a number to a base36 string. Ideally I have to do it within Magic.

 

Has anyone an example for this maybe?

 

 

Thanks,

 

 

Ramon

 



sherman levine
 

For a negative integer, I suppose you'd work with abs(starting number) and apply the appropriate sign at the end.
No idea what you would do with non-integer reals.
Sherm

On 4/6/2021 10:23 AM, sherman levine wrote:
You should be able to loop thru something like this

Update DecNum to starting number

Loop
    Digit = DecNum mod 36.    Add digit to Base36String
    DecNum=fix (DecNum/36,12,0)
Until Decnum=0

Sherm

On 4/6/2021 10:06 AM, Ramon de Wit wrote:

Hey group,

 

 

I have to convert a number to a base36 string. Ideally I have to do it within Magic.

 

Has anyone an example for this maybe?

 

 

Thanks,

 

 

Ramon

 




Steven Blank
 

Ramon,

I just uploaded a demo program to this forum's shared files area, filename: Demo_Base36Numbers.zip

Steven G. Blank
SGBlank Consulting