Jump to content

Recommended Posts

Alright not so lazy and decided to do it. Must be in between 2 and 62

Here it is

Func DecConvert($dec,$Div)
     If $div > 62 or $div < 2 Then
          Return(-1)
          EndFunc
     EndIf 
     $ans = ""
     $letterValues = ".........ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
     While $dec > $Div - 1
          $val = mod($dec,$div)
          If $val > 9 Then
               $val = stringmid($LetterValues,$val,1)
          EndIF
          $ans = $val & $ans
          $dec = int($dec / $div)
     Wend
     If $dec > 9 Then
          $dec = stringmid($LetterValues,$dec,1)
     EndIF
     Return($dec & $ans)
EndFunc

Not too bad only 20 lines of code. :whistle:

red

Edited by redndahead
Link to post
Share on other sites

Fun Test Script B)

$ans = DecConvert(8513821109,60)
MsgBox(0,"",$ans)
Exit

Func DecConvert($dec,$Div)
     If $div > 62 or $div < 2 Then
          Return(-1)
          EndFunc
     EndIf 
     $ans = ""
     $letterValues = ".........ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
     While $dec > $Div - 1
          $val = mod($dec,$div)
          If $val > 9 Then
               $val = stringmid($LetterValues,$val,1)
          EndIF
          $ans = $val & $ans
          $dec = int($dec / $div)
     Wend
     If $dec > 9 Then
          $dec = stringmid($LetterValues,$dec,1)
     EndIF
     Return($dec & $ans)
EndFunc

By the way did these work for you Lemures? since you were the one that asked for it? :whistle:

red

Link to post
Share on other sites

And anyway who uses anything higher except for base 16?

I agree with you there. I mainly use decimal/hexadecimal, and occasionally binary... (Try to avoid octal whenever possible)

I didn't really post my code as a recommended solution. I just thought about an interesting way achieve the desired results, and decided to post the code strictly for the absurdity factor. ...To paraphrase Larry, I used a sledge hammer to drive a finishing nail. :whistle:

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...