Quote: "Tier 1, how can I store enormous numbers, like 100000000000000000000000000000000 in a variable?"
You could put them in strings.
Of course if you wanted to do any maths on them, you would have to write your own routines, but it's do-able.
I had a play a while back
//
// 5,833,372,668,713,515 x 5,833,372,668,713,515
// = 34,028,236,692,093,836,022,925,143,655,225
IntA$ = "5833372668713515"
IntB$ = IntA$
IntC$ = MultiplyBig( IntA$ , IntB$ )
IntD$ = "4294967296"
IntE$ = IntD$
IntF$ = MultiplyBig( IntD$ , IntE$ )
do
print( "5833372668713515 x 5833372668713515 = 34028236692093836022925143655225 (Calculator)" )
print( IntA$ + " x " + IntB$ + " = " + IntC$ + " (function)" )
print( "" )
print( "4294967296 x 4294967296 = 18446744073709551616 (Calculator - too big for DINT )" )
print( IntD$ + " x " + IntE$ + " = " + IntF$ + " (function)" )
sync()
loop
end
function MultiplyBig( thisIntA$ , thisIntB$ )
// Splits 2 values into 4 blocks of 4 digits
// So can handle source numbers of 16 digits max
dim part[ 2 , 8 ]
lenA = len( thisIntA$ )
lenB = len( thisIntB$ )
for thisBlock = 1 to 4
if lenA = 0
thisVal = 0
else
if LenA < 5
thisVal = val( thisIntA$ )
LenA = 0
else
thisVal = val( right( thisIntA$ , 4 ) )
LenA = LenA - 4
thisIntA$ = left( thisIntA$ , LenA )
endif
endif
part[ 1,thisBlock ] = thisVal
if lenB = 0
thisVal = 0
else
if LenB < 5
thisVal = val( thisIntB$ )
LenB = 0
else
thisVal = val( right( thisIntB$ , 4 ) )
LenB = LenB - 4
thisIntB$ = left( thisIntB$ , LenB )
endif
endif
part[ 2 , thisBlock ] = thisVal
part[ 0 , thisBlock ] = 0
next thisBlock
for thisBlock = 5 to 8
part[ 0 , thisBlock ] = 0
next thisBlock
for thisBlock = 1 to 4
for otherBlock = 1 to 4
thisBoth = thisBlock + otherBlock - 1
thisResult = part[ 1 , thisBlock ] * part[ 2 , otherBlock ] + part[ 0 , thisBoth ]
if thisResult > 10000
part[ 0 , thisBoth ] = mod( thisResult , 10000 )
part[ 0 , thisBoth + 1 ] = part[ 0 , thisBoth + 1 ] + floor( thisResult / 10000 )
else
part[ 0 , thisBoth ] = thisResult
endif
next otherBlock
next thisBlock
thisIntC$ = ""
thisTop = 8
while thisTop > 0 and part[ 0 , thisTop ] = 0
dec thisTop , 1
endwhile
for thisBlock = 1 to thisTop - 1
thisIntC$ = right( "000" + str( part[ 0 , thisBlock ] ) , 4 ) + thisIntC$
next thisBlock
thisIntC$ = str( part[ 0 , thisTop ] ) + thisIntC$
endfunction thisIntC$