07-09-2023, 06:21 AM
Space_Ghost
what OS are you using?
if you are using Windows x64 then here's TerryRitchie's example converted to use LibTomath https://staging.qb64phoenix.com/showthread.php?tid=31
LibTomMath.bi (Size: 12.99 KB / Downloads: 57)
LibTomMath.bm (Size: 636 bytes / Downloads: 49)
libtommath.zip (Size: 59.37 KB / Downloads: 16)
what OS are you using?
if you are using Windows x64 then here's TerryRitchie's example converted to use LibTomath https://staging.qb64phoenix.com/showthread.php?tid=31
Code: (Select All)
_Title "Fibonacci"
$Console:Only
_Dest _Console
'$include: 'LibTomMath.bi'
Dim As mp_int fibIter
Dim As Long i, ok
Dim As Double t
t = Timer(.0001)
If mp_init(fibIter) <> 0 Then Print "failed to initialize"
For i = 1 To 5000 - 1
fibonacci fibIter, i
Print i, mp_str(fibIter, 10)
Next i
t = Timer(.0001) - t
Print "elapsed time - "; t; " seconds"
mp_clear fibIter
Sub fibonacci (f As mp_int, n As Long)
Dim As Long i
Dim As mp_int fib, fibPrev, fibPrevTemp
If mp_init(fib) <> 0 Then Print "failed to initialize"
If mp_init(fibPrev) <> 0 Then Print "failed to initialize"
If mp_init(fibPrevTemp) <> 0 Then Print "failed to initialize"
If n < 2 Then
mp_set_i32 f, n
Else
mp_set_i32 fibPrev, 1
mp_set_i32 fib, 1
For i = 2 To n - 1
ok = mp_copy(fib, fibPrevTemp)
ok = mp_add&(fibPrev, fib, fib)
ok = mp_copy(fibPrevTemp, fibPrev)
Next i
ok = mp_copy(fib, f)
mp_clear fibPrevTemp
mp_clear fibPrev
mp_clear fib
End If
End Sub
'$include: 'LibTomMath.bm'
LibTomMath.bi (Size: 12.99 KB / Downloads: 57)
LibTomMath.bm (Size: 636 bytes / Downloads: 49)
libtommath.zip (Size: 59.37 KB / Downloads: 16)