|
Post by bluatigro on Dec 31, 2018 8:40:02 GMT
this i tryed several times : more digit's after the floating point
first step : big int add
error : nothing is printed
a$ = "1" b$ = "1"
for i = 0 to 10 c$ = big.int.add$( a$ , b$ ) a$ = c$ b$ = c$ print c$ next i print "[ game over ]" end
function string$( q$ , l ) for i = 1 to l uit$ = uit$ + q$ next i string$ = uit$ end function
function big.int.add$( a$ , b$ ) if len( a$ ) < len( b$ ) then a$ = string$( "0" , len( b$ ) - len( a$ ) + 1 ) + a$ end if if len( a$ ) > len( b$ ) then b$ = string$( "0" , len( a$ ) - len( b$ ) + 1 ) + b$ end if c = 0 for i = len( a$ ) to 2 step -1 a = val( mid$( a$ , i , 1 ) ) b = val( mid$( b$ , i , 1 ) ) d = a + b + c uit$ = str$( d mod 10 ) c = int( d / 10 ) next i if left$( uit$ , 1 ) = "0" then uit$ = right$( uit$ , len( uit$ ) - 1 ) end if big.int.add$ = uit$ end function
|
|
|
Post by bluatigro on Dec 31, 2018 9:27:00 GMT
update : big int mul added
error : stil no print's
a$ = "1" b$ = "1"
for i = 0 to 10 c$ = big.int.add$( a$ , b$ ) a$ = c$ b$ = c$ print c$ next i print "[ game over ]" end
function string$( q$ , l ) for i = 1 to l uit$ = uit$ + q$ next i string$ = uit$ end function
function big.int.add$( a$ , b$ ) if len( a$ ) < len( b$ ) then a$ = string$( "0" , len( b$ ) - len( a$ ) + 1 ) + a$ end if if len( a$ ) > len( b$ ) then b$ = string$( "0" , len( a$ ) - len( b$ ) + 1 ) + b$ end if c = 0 for i = len( a$ ) to 2 step -1 a = val( mid$( a$ , i , 1 ) ) b = val( mid$( b$ , i , 1 ) ) d = a + b + c uit$ = str$( d mod 10 ) + uit$ c = int( d / 10 ) next i if left$( uit$ , 1 ) = "0" then uit$ = right$( uit$ , len( uit$ ) - 1 ) end if big.int.add$ = uit$ end function
function big.int.xd$( a$ , j ) a$ = "0" + a$ c = 0 for i = len( a$ ) to 2 step -1 a = val( mid$( a$ , i , 1 ) ) d = a * i + c uit$ = str$( d mod 10 ) + uit$ c = int( d / 10 ) next i if left$( uit$ , 1 ) = "0" then uit$ = right$( uit$ , len( uit$ ) - 1 ) end if big.int.xd$ = uit$ end function
function big.int.mul$( a$ , b$ ) a$ = "0" + a$ uit$ = "0" for i = len( a$ ) to 1 a = val( mid$( a$ , i , 1 ) ) temp$ = big.int.xd$( b$ , a ) + string$( "0" , len( a$ ) - i - 1 ) uit$ = big.int.add$( uit$ , temp$ ) next i if left$( uit$ , 1 ) = "0" then uit$ = right$( uit$ , len( uit$ ) - 1 ) end if big.int.mul$ = uit$ end function
|
|
|
Post by tsh73 on Jan 3, 2019 9:24:56 GMT
Took some dabs in big.int.add$, marked with (!!!) It looks adding for me.
a$ = "1" b$ = "1"
for i = 0 to 10 print a$;"+";b$;"="; c$ = big.int.add$( a$ , b$ ) a$ = c$ b$ = c$ print c$ next i print "[ game over ]" end
function string$( q$ , l ) for i = 1 to l uit$ = uit$ + q$ next i string$ = uit$ end function
function big.int.add$( a$ , b$ ) if len( a$ ) < len( b$ ) then ' a$ = string$( "0" , len( b$ ) - len( a$ ) + 1 ) + a$'!!! a$ = string$( "0" , len( b$ ) - len( a$ ) ) + a$ end if if len( a$ ) > len( b$ ) then ' b$ = string$( "0" , len( a$ ) - len( b$ ) + 1 ) + b$'!!! b$ = string$( "0" , len( a$ ) - len( b$ ) ) + b$ end if c = 0 for i = len( a$ ) to 1 step -1 'for i = len( a$ ) to 2 step -1 '!!! a = val( mid$( a$ , i , 1 ) ) b = val( mid$( b$ , i , 1 ) ) d = a + b + c uit$ = str$( d mod 10 ) + uit$ c = int( d / 10 ) next i if c then '!!! overflow uit$ = str$( c ) + uit$ end if if left$( uit$ , 1 ) = "0" then uit$ = right$( uit$ , len( uit$ ) - 1 ) end if big.int.add$ = uit$ end function
function big.int.xd$( a$ , j ) a$ = "0" + a$ c = 0 for i = len( a$ ) to 2 step -1 a = val( mid$( a$ , i , 1 ) ) d = a * i + c uit$ = str$( d mod 10 ) + uit$ c = int( d / 10 ) next i if left$( uit$ , 1 ) = "0" then uit$ = right$( uit$ , len( uit$ ) - 1 ) end if big.int.xd$ = uit$ end function
function big.int.mul$( a$ , b$ ) a$ = "0" + a$ uit$ = "0" for i = len( a$ ) to 1 a = val( mid$( a$ , i , 1 ) ) temp$ = big.int.xd$( b$ , a ) + string$( "0" , len( a$ ) - i - 1 ) uit$ = big.int.add$( uit$ , temp$ ) next i if left$( uit$ , 1 ) = "0" then uit$ = right$( uit$ , len( uit$ ) - 1 ) end if big.int.mul$ = uit$ end function
|
|
|
Post by bluatigro on Jan 4, 2019 8:45:06 GMT
update : try at multiply()
error : strxdigit$() is good now multiply$() not jet good
'' bluatigo 4 jan 2019 '' str_int is a number in N '' if i have divide and subtrackt '' i wil try str_int in Z '' if i have that '' i wil try str_float in R '' if i have that '' i wil try sqr( str_float )
a$ = "10" b$ = "20" e$ = "123"
for i = 0 to 11 print a$ ; " * " ; b$ ; " = " ; c$ = multiply$( a$ , b$ ) d$ = strxdigit$( e$ , i ) a$ = c$ b$ = c$ print c$ , d$ next i print "[ game over ]" end
function string$( q$ , l ) for i = 1 to l uit$ = uit$ + q$ next i string$ = uit$ end function
function big.int.add$( a$ , b$ ) '' ( str_int ) output = ( str_int ) a + ( str_int ) b '' adding a and b in N if len( a$ ) < len( b$ ) then a$ = string$( "0" , len( b$ ) - len( a$ ) ) + a$ end if if len( a$ ) > len( b$ ) then b$ = string$( "0" , len( a$ ) - len( b$ ) ) + b$ end if c = 0 for i = len( a$ ) to 1 step -1 a = val( mid$( a$ , i , 1 ) ) b = val( mid$( b$ , i , 1 ) ) d = a + b + c uit$ = str$( d mod 10 ) + uit$ c = int( d / 10 ) next i if c then uit$ = str$( c ) + uit$ end if if left$( uit$ , 1 ) = "0" then uit$ = right$( uit$ , len( uit$ ) - 1 ) end if big.int.add$ = uit$ end function
function strxdigit$( a$ , j ) '' ( str_int ) output = ( str_int ) a * ( digit ) j '' a in N '' j in [ 0 ... 9 ] c = 0 for i = len( a$ ) to 1 step -1 a = val( mid$( a$ , i , 1 ) ) d = a * j + c uit$ = str$( d mod 10 ) + uit$ c = int( d / 10 ) next i if c then uit$ = str$( c ) + uit$ end if strxdigit$ = uit$ end function
function multiply$( a$ , b$ ) '' ( str_int ) output = ( str_int ) a * ( str_int ) b '' a and b in N uit$ = "0" for i = len( a$ ) to 1 a = val( mid$( a$ , i , 1 ) ) temp$ = strxdigit$( b$ , a ) _ + string$( "0" , len( a$ ) - i ) uit$ = big.int.add$( uit$ , temp$ ) next i multiply$ = uit$ end function
|
|
|
Post by tsh73 on Jan 4, 2019 13:55:19 GMT
It was missing "STEP -1" in function multiply$( a$ , b$ )
|
|
|
Post by bluatigro on Jan 5, 2019 10:25:27 GMT
update : +() *() -() fixed in N
error : /() not good jet
'' bluatigo 4 jan 2019 '' str_int is a number in N '' if i have divide and subtrackt '' i wil try str_int in Z '' if i have that '' i wil try str_float in R '' if i have that '' i wil try sqr( str_float )
a$ = "1" b$ = "2"
d$ = "120" e$ = "32"
for i = 0 to 9 print a$ ; " * " ; b$ ; " = " ; c$ = multiply$( a$ , b$ ) a$ = c$ print c$ next i input "[ test * end . push return ]" ; in$
for i = 0 to 9 print d$ ; " - " ; b$ ; " = " ; f$ = subtrackt$( d$ , b$ ) d$ = f$ print f$ next i
input "[ text - end . push return ]" ; in$
q$ = "20000" for i = 1 to 10 print q$ + " / " ; i ; " = " ; divide$( q$ , str$( i ) ) next i
print "[ game over . ]"
end
function string$( q$ , l ) for i = 1 to l uit$ = uit$ + q$ next i string$ = uit$ end function
function big.int.add$( a$ , b$ ) '' ( str_int ) output = ( str_int ) a + ( str_int ) b '' adding a and b in N if len( a$ ) < len( b$ ) then a$ = string$( "0" , len( b$ ) - len( a$ ) ) + a$ end if if len( a$ ) > len( b$ ) then b$ = string$( "0" , len( a$ ) - len( b$ ) ) + b$ end if c = 0 for i = len( a$ ) to 1 step -1 a = val( mid$( a$ , i , 1 ) ) b = val( mid$( b$ , i , 1 ) ) d = a + b + c uit$ = str$( d mod 10 ) + uit$ c = int( d / 10 ) next i if c then uit$ = str$( c ) + uit$ end if if left$( uit$ , 1 ) = "0" then uit$ = right$( uit$ , len( uit$ ) - 1 ) end if big.int.add$ = uit$ end function
function strxdigit$( a$ , j ) '' ( str_int ) output = ( str_int ) a * ( digit ) j '' a in N '' j in [ 0 ... 9 ] c = 0 for i = len( a$ ) to 1 step -1 a = val( mid$( a$ , i , 1 ) ) d = a * j + c uit$ = str$( d mod 10 ) + uit$ c = int( d / 10 ) next i if c then uit$ = str$( c ) + uit$ end if strxdigit$ = uit$ end function
function multiply$( a$ , b$ ) '' ( str_int ) output = ( str_int ) a * ( str_int ) b '' a and b in N uit$ = "0" for i = len( a$ ) to 1 step -1 a = val( mid$( a$ , i , 1 ) ) temp$ = strxdigit$( b$ , a ) _ + string$( "0" , len( a$ ) - i ) uit$ = big.int.add$( uit$ , temp$ ) next i multiply$ = uit$ end function
function int.smal( a$ , b$ ) '' is a < b ? uit = 0 if len( a$ ) < len( b$ ) then uit = 1 end if if len( a$ ) = len( b$ ) then if uit = 0 then for i = 1 to len( a$ ) if mid$( a$ , i , 1 ) < mid$( b$ , i , 1 ) then uit = 1 end if next i end if end if int.smal = uit end function
function subtrackt$( a$ , b$ ) if len( b$ ) < len( a$ ) then b$ = string$( "0" , len( a$ ) - len( b$ ) ) + b$ end if c = 0 for i = len( a$ ) to 1 step -1 a = val( mid$( a$ , i , 1 ) ) b = val( mid$( b$ , i , 1 ) ) d = a - b - c if d < 0 then d = d + 10 c = 1 else c = 0 end if uit$ = str$( d ) + uit$ next i while left$( uit$ , 1 ) = "0" uit$ = right$( uit$ , len( uit$ ) - 1 ) wend subtrackt$ = uit$ end function
function divide$( a$ , b$ ) tel = 0 i = len( b$ ) while mid$( b$ , i , 1 ) = "0" tel = tel + 1 i = i - 1 wend while int.smal( b$ , a$ ) b$ = b$ + "0" wend b$ = left$( b$ , len( b$ ) - 1 ) while right$( b$ , 1 ) = "0" temp$ = "0" digit = 1 while int.smal( temp$ , a$ ) temp$ = strxdigit$( b$ , digit ) digit = digit + 1 wend digit = digit - 1 uit$ = str$( digit ) + uit$ a$ = subtrackt$( a$ , strxdigit$( b$ , digit ) ) b$ = left$( b$ , len( b$ ) - 1 ) wend while left$( uit$ , 1 ) = "0" uit$ = right$( uit$ , len( uit$ ) - 1 ) wend divide$ = uit$ + string$( "0" , tel ) end function
|
|