'you must use $NoPrefix
Dest Console
Const NUMBER_OF_DIGITS
= 620 ' you must have NUMBER_OF_DIGITS defined -- not to exceed 1024 ' before including decfloat.bi
'$include: 'decfloat.bi'
'======================================================================
' your code follows
Dim As decfloat first
, last
, fn, m
, x
, y
, z
, v
'str2fp fn, "4784969" ' "4784969"
fpipow
fn, fn, 1024, NUM_DWORDS
str2fp m, "10000000000000000000000000000000000000000"
si2fp x, 5, NUM_DWORDS
fpsqr x, x, NUM_DWORDS
si2fp z, 1, NUM_DWORDS
fpadd y, x, z, NUM_DWORDS
fpdiv_si y, y, 2, NUM_DWORDS
fplog y, y, NUM_DWORDS
fpmul y
, y
, fn, NUM_DWORDS
fplog z, x, NUM_DWORDS
fpsub y, y, z, NUM_DWORDS
si2fp x, 10, NUM_DWORDS
fplog v, x, NUM_DWORDS
fpdiv y, y, v, NUM_DWORDS
fpfrac z, y, NUM_DWORDS
fppow y, x, z
s = fp2str(y, 40)
s = fp2str(last, NUMBER_OF_DIGITS)
Sub fib
(k
As decfloat
, m
As decfloat
, fibonacci
As decfloat
) Dim As decfloat b
, x
, y
, xx
, temp
, tmp
, rn
str2fp rn, ".05"
si2fp tmp, 1, NUM_DWORDS
If fpcmp
(k
, tmp
, NUM_DWORDS
) <= 0 Then fibonacci = k
si2fp x, 1, NUM_DWORDS
si2fp y, 0, NUM_DWORDS
fplog tmp, k, NUM_DWORDS
si2fp temp, 2, NUM_DWORDS
fplog xx, temp, NUM_DWORDS
fpdiv b, tmp, xx, NUM_DWORDS
fpfix tmp, b
bit_length = fp2dbl(tmp)
si2fp b, 2, NUM_DWORDS
fpipow b, b, bit_length - 1, NUM_DWORDS
fpmul xx, x, x, NUM_DWORDS
fpdiv xx, xx, m, NUM_DWORDS
fpfrac xx, xx, NUM_DWORDS
fpmul xx, xx, m, NUM_DWORDS
fpadd xx, xx, rn, NUM_DWORDS
fpfix xx, xx
fpmul x, x, y, NUM_DWORDS
fpmul_si x, x, 2, NUM_DWORDS
fpadd x, xx, x, NUM_DWORDS
fpdiv x, x, m, NUM_DWORDS
fpfrac x, x, NUM_DWORDS
fpmul x, x, m, NUM_DWORDS
fpadd x, x, rn, NUM_DWORDS
fpfix x, x
fpmul y, y, y, NUM_DWORDS
fpadd y, y, xx, NUM_DWORDS
fpdiv y, y, m, NUM_DWORDS
fpfrac y, y, NUM_DWORDS
fpmul y, y, m, NUM_DWORDS
fpadd y, y, rn, NUM_DWORDS
fpfix y, y
fpdiv temp, k, b, NUM_DWORDS
temp = x
fpadd x, x, y, NUM_DWORDS
fpdiv x, x, m, NUM_DWORDS
fpfrac x, x, NUM_DWORDS
fpmul x, x, m, NUM_DWORDS
fpadd x, x, rn, NUM_DWORDS
fpfix x, x
y = temp
fpdiv_si b, b, 2, NUM_DWORDS
fibonacci = x
' end of your code
' you must include decfloat.bm
'$include: 'decfloat.bm'