Jump to content

36-base number system


Recommended Posts

When I input for example the number 38 to script, it would give me code B1. When given the number 0, output would be 1. Give the number 11 and output would be A. So the number system would be based on 36 symbols (ABCDEFGHIJKLMNOPQRSTUVWXY1234567890). Got it :whistle: ? I have idea of defining all of the numbers up to 36 and then reseting some variable and adding +1 to the next variable and... Then I remembered that there's some table things, where you can fill the table with any given symbols and access to them easily afterwards. But I have no idea what would be the next step :P . So how would I manage to do working 36-based number system?

Edited by ValdeZ
Link to comment
Share on other sites

When I input for example the number 38 to script, it would give me code B1. When given the number 0, output would be 1. Give the number 11 and output would be A. So the number system would be based on 36 symbols (ABCDEFGHIJKLMNOPQRSTUVWXY1234567890). Got it :whistle: ?

No, I don't get it since your table does not correspond to the output you want.

But put your table in an array. Use mod to figure out number positions and do a lookup in the array.

Link to comment
Share on other sites

No, I don't get it since your table does not correspond to the output you want.

But put your table in an array. Use mod to figure out number positions and do a lookup in the array.

I messed up a bit :whistle: . Meant:

input 1, output 1

input 11, output B

input 35, output 10

input 36, output 11

I have put A-Z and 0-9 symbols to one array. But how I supposed to do hmm, maths with these numbers? For example 35+1 (this is 10 number based) and output should be 11? I thought that I could make something like

$variable10based

If $variable10based = 34

$variable10based2 = $variable10based2 + 1

$variable10based = 0

; and then... no idea because this doesn't look good

:P I can't

Link to comment
Share on other sites

This is exactly reverse of what you want.. Just to make it more interesting for you. :whistle:

MsgBox(0, "", _36BaseToDec("AHX") )

Func _36BaseToDec($s_Number)
    Local $s_Return = 0
    $s_Number = StringUpper($s_Number)
    $s_Split = StringSplit($s_Number,"")
    If $s_Split[0] <= 0 Then
        SetError(1)
        Return 0
    Else
        For $s_X = $s_Split[0] To 1 Step -1
            $s_Base = Asc($s_Split[$s_X])
            Switch $s_Base
                Case 0x30 To 0x39
                    $s_Add = 10^(($s_X-$s_Split[0])*-1) * ($s_Base-0x30)
                Case 0x41 To 0x5A
                    $s_Add = 10^(($s_X-$s_Split[0])*-1) * ($s_Base-0x41+10)
                Case Else
                    SetError(2)
                    Return 0
            EndSwitch
            $s_Return += $s_Add
;           MsgBox(0, "", "Step: " & 10^(($s_X-$s_Split[0])*-1) & @CRLF & _
;           "Char: " & $s_Split[$s_X] & @CRLF & _
;           "This chars value: " & $s_Add / (10^(($s_X-$s_Split[0])*-1)) & " * " & 10^(($s_X-$s_Split[0])*-1) & " = " & $s_Add  & @CRLF & _
;           "new return value: " & $s_Return)
        Next
        SetError(0)
        Return $s_Return
    EndIf
EndFunc
Edited by Manadar
Link to comment
Share on other sites

:whistle: Thanks! This may take some time to learn what those commands do, but then I believe that I can do what I want :P

No problem, ValdeZ. The mathematics behind these are not hard to understand, only I haven't been able to find a website that explains them properly.. Do you know the results from this function are correct?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...