Jump to content
Sign in to follow this  

Problem with base conversion algorithm

Recommended Posts


This algorithm is supposed to convert base 10 to base 48.

Func convertNum($n)
    ;This function takes a base 10 number and converts it to base 48
    ;the values for each place are currently represented in decimal, but will soon be shown as a-z and A-V.

    ;Find the highest base 48 value that we will need.
    $j = 0

    While 1
        If (48^$j * 48) - 1 <= $n Then
            $j += 1


    ;$j now contains the highest power of 48 needed.
    Local $outArray[$j + 1]
    $outStr = ""

    For $k = $j To 0 Step -1
        ;represent the value for this place
        $outArray[$k] = Int($n / (48 ^ $k))

        ;remove it from the original number
        $n -= ($outArray[$k] * (48 ^ $k))


    For $i = 0 To $j
        ;show the values for each place, seperated by a comma.
        $outStr &= $outArray[$i] & ","

    Return $outStr


What exactly is wrong?

Share this post

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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.