Big Integer handling in Blitz Basic 2D?

Miscellaneous Forums/General Discussion/Big Integer handling in Blitz Basic 2D?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

i had a quick try. this works but only for positive values. i got stuck then.

i think the best way is to write a dll to receive a string from b+, do the maths function as 64-bit values, and return the result as a string.

Graphics 640,480,0,2

value2$="100000020"
value1$="3000"
result$=AddLongString(value1$,value2$)

Print "value1="+value1
Print "value2="+value2
Print "result="+result+" ("+(100000020+3000)+")"
WaitKey
End

Function AddLongString$(val1$,val2$)

 Local val1hi,val1lo,val2hi,val2lo,reshi$,reslo$,i,pad$
 If (Len(val1$)>9) val1hi=Int(Left(val1$,Len(val1$)-9))
 val1lo=Int(Right(val1$,9))
 If (Len(val2$)>9) val2hi=Int(Left(val2$,Len(val2$)-9))
 val2lo=Int(Right(val2$,9))
 If (val1hi+val2hi<>0) reshi$=val1hi+val2hi
 If (val1lo+val2lo<>0) reslo$=val1lo+val2lo
 For i=1 To 9-Len(reslo$)
  pad$=pad$+"0" 
 Next
 Return reshi$+pad$+reslo$

End Function