Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
new approach to base conversion system and math library
#1
here is what I got so far it handles up to 512 digits of any number in any base the number you enter starts with the base the number is in you can give a sign and it should interpret that correctly and the number is terminated by a symbol # this can handle bases up to base 81 here it is so far:
Code: (Select All)
Dim nmbr$1(63, 511)
Dim avail$1(80)
Dim cnvtbk~%(255)
For s = 0 To 255
    cnvtbk~%%(s) = 255
Next s
For s = 0 To 78
    cnvtbk~%%(s + 48) = s
Next s
cnvtbk~%%(38) = 79
cnvtbk~%%(47) = 80
cnvtbk~%%(45) = 99
cnvtbk~%%(43) = 101
cnvtbk~%%(46) = 124
For s = 0 To 78
    avail$1(s) = Chr$(s + 48)
Next s
avail$1(79) = "&"
avail$1(80) = "/"
Print "    0123456789"
For s = 0 To 7
    Print Chr$(s + 48); "  ";
    For t = 0 To 9
        Print avail$1(s * 10 + t);
    Next t
    Print ""
Next s
Print Chr$(56); "  "; avail$1(80)

Print "enter each number using the format Base sign(+ or -) whole part . then fractional part terminat the number with a #"
Print "use a decimal point as a decimal point the sign be included if omitted the number is assumed to be positive"
Print "use the chart shown to determine digits in the number , for the base use the actual symbol or number that corresponds"
Print "to the highest number reachable in the base used so a 1 for base means base 2 6 for base 7  9 for base 10 and so on"
Print "this can handle up to base 81 for example pi in base 81 is given as /3.;U/# this to 4 base 81 places"
Print " or thata same value pi in base 81 can be /+3.;U/# a negative value would be like this 9-57.94# to indicate -57.94 in base 10"
Print "this program will take 2 numbers you enter in and multiply them max number of digits is 512 total and will output"
Print " the answer in whatever base you chose"
Input "target base : "; tbas$1
Input "first number : "; data1$
Input "second number : "; data2$
If (Len(data1$) + Len(data2$)) > 512 Then Print "numbers are too large"

Reply
#2
with This I plan to have it multiply 2 numbers you enter in in any given base and output the answer into the base you choose, If I am successful it will form the basis from which I will create a library of math operations that can multiply any two numbers in any base up to 81 the table for the bases up to 81 is basically value +48 for values 0 -78
and for value 79 and 80 I borrowed two characters from the ascii table that I am not likely to use it supports using a sign, and if the value is positive no sign is needed, positive number is assumed if no sign is present the decimal point is searched for and no math calculations will be done with it but its position in the numbers will be measured/ counted so that the correct position for the decimal point can be restored into the answer in the correct location. I think it might be possible to convert the whole number and to multiply the numbers keeping the whole number and just multiplying all the digits keeping track of what position each of the results are going to go in to...you could possibly multiply the digits from high to low or low to hi but basically I will need to make a loop that multiply every digit in one number by every digit in the other number and in some of the cases there might be a "carry" from another calculation.

oh and it is not finished yet though This is just the data entry part pretty much...
Reply
#3
this is what I got so far I decided to upgrade it to a base 2 - 100 conversion program it does not some to be functioning properly I need help there seems to be an error at or after reloop2 can you see what that error is?
Code: (Select All)
Dim nmbr$1(63, 511)
Dim avail$1(99)
Dim cnvtbk~%%(255)
For s = 0 To 255
    cnvtbk~%%(s) = 255
Next s
For s = 0 To 78
    cnvtbk~%%(s + 48) = s
    avail$1(s) = Chr$(s + 48)
Next s
laze$ = "!$%&()*/"
For pel% = 224 To 236
    laze$ = laze$ + Chr$(pel%)
Next pel%
For s = 79 To 99
    p% = Asc(Mid$(laze$, s - 78, 1))
    cnvtbk~%%(p%) = s
    avail$1(s) = Chr$(p%)
Next s
Print "    0123456789"
For s = 0 To 9
    Print Chr$(s + 48); "  ";
    For t = 0 To 9
        If (s * 10 + t) <= 99 Then
            Print avail$1(s * 10 + t);
        End If
    Next t
    Print ""
Next s
ing$ = ""
While ing$ = "": ing$ = InKey$: Wend
Print "enter each number using the format Base sign(+ or -) whole part . then fractional part terminat the number with a #"
Print "use a decimal point as a decimal point the sign be included if omitted the number is assumed to be positive"
Print "use the chart shown to determine digits in the number , for the base use the actual symbol or number that corresponds"
Print "to the highest number reachable in the base used so a 1 for base means base 2 6 for base 7  9 for base 10 and so on"
Print "this can handle up to base 81 for example pi in base 81 is given as /3.;U/# this to 4 base 81 places"
Print " or thata same value pi in base 81 can be /+3.;U/# a negative value would be like this 9-57.94# to indicate -57.94 in base 10"
Print "this program will take 2 numbers you enter in and multiply them max number of digits is 512 bit equivelent total and will output"
Print " the answer in whatever base you chose"
Print "target base : ";
bse$ = getbas$
Print "first number : ";
num1$ = getnum$
Print "second number : ";
num2$ = getnum$
If 6.33985 * (Len(data1$) + Len(data2$) - 8) > 512 Then Print "numbers are too large"


Data 33,36,37,38,40,41,42,47  '79,80,81,82,83,84,85,86
Data 224,225,233,235        '87,88,89,90


Function getnum$ ()
    num$ = ""
    hiasc = 0
    reloop: wi$ = ""
    While wi$ = ""
        wi$ = InKey$
    Wend

    If hiasc = 1 Then
        wi$ = ""
        While wi$ = ""
            wi$ = InKey$
            If wi$ = "0" Then
                wi$ = Chr$(224)
                Print wi$;
            End If
            If wi$ = "1" Then
                wi$ = Chr$(225)
                Print wi$;
            End If

            If wi$ = "2" Then
                wi$ = Chr$(226)
                Print wi$;
            End If

            If wi$ = "3" Then
                wi$ = Chr$(227)
                Print wi$;
            End If

            If wi$ = "4" Then
                wi$ = Chr$(228)
                Print wi$;
            End If
            If wi$ = "5" Then
                wi$ = Chr$(229)
                Print wi$;
            End If
            If wi$ = "6" Then
                wi$ = Chr$(230)
                Print wi$;
            End If
            If wi$ = "7" Then
                wi$ = Chr$(231)
                Print wi$;
            End If
            If wi$ = "8" Then
                wi$ = Chr$(232)
                Print wi$;
            End If
            If wi$ = "9" Then
                wi$ = Chr$(233)
                Print wi$;
            End If
            If wi$ = "A" Then
                wi$ = Chr$(234)
                Print wi$;
            End If
            If wi$ = "B" Then
                wi$ = Chr$(235)
                Print wi$;
            End If
            If wi$ = "C" Then
                wi$ = Chr$(236)
                Print wi$;
            End If
            hiasc = 0
        Wend
    End If
    If Asc(wi$) > 47 And Asc(wi$) < 127 Then
        num$ = num$ + wi$
        Print wi$;
    End If
    If wi$ = "+" Then
        num$ = num$ + wi$
        Print wi$;
    End If
    If wi$ = "-" Then
        num$ = num$ + wi$
        Print wi$;
    End If
    If wi$ = "." Then
        num$ = num$ + wi$
        Print wi$;
    End If
    If wi$ = "#" Then
        num$ = num$ + wi$
        Print wi$;
    End If
    If Asc(wi$) > 127 Then num$ = num$ + wi$
    If wi$ = Chr$(39) Then hiasc = 1
    If wi$ <> "#" Then GoTo reloop
    getnum$ = num$
End Function


Function getbas$ ()
    num$ = ""
    hiasc = 0
    reloop2: wi$ = ""
    While wi$ = ""
        wi$ = InKey$
    Wend

    If hiasc = 1 Then
        wi$ = ""
        While wi$ = ""
            wi$ = InKey$
            If wi$ = "0" Then
                wi$ = Chr$(224)
                Print wi$;
            End If
            If wi$ = "1" Then
                wi$ = Chr$(225)
                Print wi$;
            End If

            If wi$ = "2" Then
                wi$ = Chr$(226)
                Print wi$;
            End If

            If wi$ = "3" Then
                wi$ = Chr$(227)
                Print wi$;
            End If

            If wi$ = "4" Then
                wi$ = Chr$(228)
                Print wi$;
            End If
            If wi$ = "5" Then
                wi$ = Chr$(229)
                Print wi$;
            End If
            If wi$ = "6" Then
                wi$ = Chr$(230)
                Print wi$;
            End If
            If wi$ = "7" Then
                wi$ = Chr$(231)
                Print wi$;
            End If
            If wi$ = "8" Then
                wi$ = Chr$(232)
                Print wi$;
            End If
            If wi$ = "9" Then
                wi$ = Chr$(233)
                Print wi$;
            End If
            If wi$ = "A" Then
                wi$ = Chr$(234)
                Print wi$;
            End If
            If wi$ = "B" Then
                wi$ = Chr$(235)
                Print wi$;
            End If
            If wi$ = "C" Then
                wi$ = Chr$(236)
                Print wi$;
            End If
            hiasc = 0
        Wend
    End If
    If Asc(wi$) > 47 And Asc(wi$) < 127 Then
        num$ = num$ + wi$
        Print wi$;
    End If
    If wi$ = "+" Then
        num$ = num$ + wi$
        Print wi$;
    End If
    If wi$ = "-" Then
        num$ = num$ + wi$
        Print wi$;
    End If
    If wi$ = "." Then
        num$ = num$ + wi$
        Print wi$;
    End If
    If wi$ = "#" Then
        num$ = num$ + wi$
        Print wi$;
    End If
    If Asc(wi$) > 127 Then num$ = num$ + wi$
    If wi$ = Chr$(39) Then hiasc = 1
    If hiasc = 1 Then reloop2
        getbas$ = num$
End Function
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Keyhit to Inkey Conversion Project Pete 7 582 01-11-2026, 01:26 AM
Last Post: Pete
  3D Sun-Earth-Moon System (_MAPTRIANGLE3D) Magdha 8 741 11-11-2025, 10:09 AM
Last Post: Magdha
  QB UI Library aadityap0901 6 1,176 08-02-2025, 05:13 PM
Last Post: aadityap0901
  Everything Date Library in progress SMcNeill 2 714 05-14-2025, 08:36 PM
Last Post: SMcNeill
  universal base conversion program possibly for a base conversion library later on Dragoncat 22 3,021 04-24-2025, 02:08 AM
Last Post: Dragoncat

Forum Jump:


Users browsing this thread: 1 Guest(s)