''$Checking:Off
Const NUM_DIGITS
= 9 * 312 '50731 '3963 Const NUM_DWORDS
= NUM_DIGITS \
9 Const NUM_BYTES
= 2 + 4 * NUM_DWORDS
Const BIAS
= 1073741824 '2 ^ 30
' Error definitions
Const DIVZ_ERR
= 1 'Divide by zero Const EXPO_ERR
= 2 'Exponent overflow error Const EXPU_ERR
= 3 'Exponent underflow error
fib = "999999999999999999999998999999999999999999999999"
s = dec2str_fix(y)
j = 1
j = j + 48
Print "fib by reciprocal time is "; t;
" seconds"
'Call str2dec("1", x)
'z = x
't = Timer
'For i = 1 To 100000
'Call fpmul_si(z, z, i)
'Next
't = Timer - t
'Print dec2str(z)
'Print "factorial 10000 in "; t; " seconds"
Dim As Long j
, s
, d
, e
, ep
, ex
, es
, i
, f
, fp
, fln
j = 1
s = 1
d = 0
e = 0
ep = 0
ex = 0
es = 1
i = 0
f = 0
fp = 0
f1 = ""
f2 = ""
f3 = ""
j = j + 1
es = -es
c = ""
j = j + 1
j = j + 1
If (c
> "/") And (c
< ":") Then 'c is digit between 0 and 9 f3 = f3 + c
ex
= 10 * ex
+ (Asc(c
) - 48) j = j + 1
j = j + 1
s = -s
j = j + 1
j = j + 1
j = j + 1
d = 1
If (c
> "/") And (c
< ":") Then 'c is digit between 0 and 9 j = j + 1
e = e - 1
j = j + 1
f1 = f1 + c
i = i + 1
fp = 1
f2 = f2 + c
f = f + 1
ep = 1
j = j + 1
skip_while:
f = 0
f2 = ""
n.sign = s
ex = es * ex - 1 + i + e
f1 = f1 + f2
f1
= Mid$(f1
, 1, ((NUM_DWORDS
* 9) + 1)) f1 = f1 + "0"
j = 1
For i
= 0 To NUM_DWORDS
- 1 Mid$(n.mantissa
, 4 * i
+ 1, 4) = MKL$(ulng
) j = j + 9
If fp
Then n.exponent
= (ex
+ BIAS
+ 1) Else n.exponent
= 0
ex
= (n.exponent
And &H7FFFFFFF) - BIAS
- 1 ex = 0
For i
= 1 To NUM_DWORDS
- 1 v = v + ts
v = v + f
dec2str = v
ex
= (n.exponent
And &H7FFFFFFF) - BIAS
- 1 ex = 0
v = ts
For i
= 1 To NUM_DWORDS
- 1 v = v + ts
dec2str_fix = s + v
ex
= (n.exponent
And &H7FFFFFFF) - BIAS
- 1 ex = 0
v = v + ts
v = v + f
Sub RSHIFT_1
(mantissa
As decfloat
) v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) \
10 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
- 1) + 1, 4)) Mod 10 v2 = v2 * 100000000 + v1
Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v2
) Mid$(mantissa.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * 0 + 1, 4)) \
10)
Sub LSHIFT_1
(mantissa
As decfloat
) For i
= 0 To NUM_DWORDS
- 2 v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) Mod 100000000 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) \
100000000 Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v1
* 10 + v2
) Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) Mod 100000000) Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4) = MKL$(10 * CVL(Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4)) Mod 100000000)
Sub RSHIFT_2
(mantissa
As decfloat
) v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) \
100 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
- 1) + 1, 4)) Mod 100 v2 = v2 * 10000000 + v1
Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v2
) Mid$(mantissa.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * 0 + 1, 4)) \
100)
Sub LSHIFT_2
(mantissa
As decfloat
) For i
= 0 To NUM_DWORDS
- 2 v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) Mod 10000000 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) \
10000000 Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v1
* 100 + v2
) Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) Mod 10000000) Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4) = MKL$(100 * (CVL(Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4)) Mod 10000000))
Sub RSHIFT_3
(mantissa
As decfloat
) v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) \
1000 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
- 1) + 1, 4)) Mod 1000 v2 = v2 * 1000000 + v1
Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v2
) Mid$(mantissa.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * 0 + 1, 4)) \
1000)
Sub LSHIFT_3
(mantissa
As decfloat
) For i
= 0 To NUM_DWORDS
- 2 v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) Mod 1000000 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) \
1000000 Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v1
* 1000 + v2
) Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) Mod 1000000) Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4) = MKL$(1000 * (CVL(Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4)) Mod 1000000))
Sub RSHIFT_4
(mantissa
As decfloat
) v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) \
10000 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
- 1) + 1, 4)) Mod 10000 v2 = v2 * 100000 + v1
Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v2
) Mid$(mantissa.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * 0 + 1, 4)) \
10000)
Sub LSHIFT_4
(mantissa
As decfloat
) For i
= 0 To NUM_DWORDS
- 2 v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) Mod 100000 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) \
100000 Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v1
* 10000 + v2
) Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) Mod 100000) Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4) = MKL$(10000 * (CVL(Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4)) Mod 100000))
Sub RSHIFT_5
(mantissa
As decfloat
) v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) \
100000 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
- 1) + 1, 4)) Mod 100000 v2 = v2 * 10000 + v1
Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v2
) Mid$(mantissa.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * 0 + 1, 4)) \
100000)
Sub LSHIFT_5
(mantissa
As decfloat
) For i
= 0 To NUM_DWORDS
- 2 v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) Mod 10000 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) \
10000 Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v1
* 100000 + v2
) Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) Mod 10000) Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4) = MKL$(100000 * (CVL(Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4)) Mod 10000))
Sub RSHIFT_6
(mantissa
As decfloat
) v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) \
1000000 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
- 1) + 1, 4)) Mod 1000000 v2 = v2 * 1000 + v1
Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v2
) Mid$(mantissa.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * 0 + 1, 4)) \
1000000)
Sub LSHIFT_6
(mantissa
As decfloat
) For i
= 0 To NUM_DWORDS
- 2 v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) Mod 1000 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) \
1000 Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v1
* 1000000 + v2
) Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) Mod 1000) Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4) = MKL$(1000000 * (CVL(Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4)) Mod 1000))
Sub RSHIFT_7
(mantissa
As decfloat
) v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) \
10000000 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
- 1) + 1, 4)) Mod 10000000 v2 = v2 * 100 + v1
Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v2
) Mid$(mantissa.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * 0 + 1, 4)) \
10000000)
Sub LSHIFT_7
(mantissa
As decfloat
) For i
= 0 To NUM_DWORDS
- 2 v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) Mod 100 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) \
100 Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v1
* 10000000 + v2
) Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) Mod 100) Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4) = MKL$(10000000 * (CVL(Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4)) Mod 100))
Sub RSHIFT_8
(mantissa
As decfloat
) v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) \
100000000 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
- 1) + 1, 4)) Mod 100000000 v2 = v2 * 10 + v1
Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v2
) Mid$(mantissa.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * 0 + 1, 4)) \
100000000)
Sub LSHIFT_8
(mantissa
As decfloat
) For i
= 0 To NUM_DWORDS
- 2 v1
= CVL(Mid$(mantissa.mantissa
, 4 * i
+ 1, 4)) Mod 10 v2
= CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) \
10 Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = MKL$(v1
* 100000000 + v2
) Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4) = MKL$(CVL(Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4)) Mod 10) Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4) = MKL$(100000000 * (CVL(Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4)) Mod 10))
Sub RSHIFT_9
(mantissa
As decfloat
) Mid$(mantissa.mantissa
, 4 * i
+ 1, 4) = Mid$(mantissa.mantissa
, 4 * (i
- 1) + 1, 4) Mid$(mantissa.mantissa
, 4 * 0 + 1, 4) = MKL$(0)
Sub LSHIFT_9
(mantissa
As decfloat
) For i
= 0 To NUM_DWORDS
- 2 Mid$(mantissa.mantissa
, 4 * i
+ 1) = Mid$(mantissa.mantissa
, 4 * (i
+ 1) + 1, 4) Mid$(mantissa.mantissa
, 4 * (NUM_DWORDS
- 1) + 1, 4) = MKL$(0)
If x.exponent
= y.exponent
Then For i
= 0 To NUM_DWORDS
- 1 c
= CVL(Mid$(x.mantissa
, 4 * i
+ 1, 4)) - CVL(Mid$(y.mantissa
, 4 * i
+ 1, 4)) cmp = -1
cmp = 0
cmp = 1
If x.exponent
< y.exponent
Then cmp = -1
If x.exponent
> y.exponent
Then cmp = 1
' normalize the number in fac1
' all routines exit through this one.
' we leave ax=0 if normalization was
' ok...else ax = error code.
'see if the mantissa is all zeros.
'if so, set the exponent and sign equal to 0.
er = 0: f = 0
For i
= 0 To NUM_DWORDS
- 1 fac1.exponent = 0
fac1.sign = 0
'if the highmost nibble in fac1_man is nonzero,
'shift the mantissa right 1 nibble and
'increment the exponent
fac1.exponent = fac1.exponent + 1
'now shift fac1_man 1 to the left until a
'nonzero digit appears in the next-to-highest
'nibble of fac1_man. decrement exponent for
'each shift.
fac1.exponent = fac1.exponent - 1
NORM_FAC1 = EXPU_ERR
'check for overflow/underflow
NORM_FAC1 = EXPO_ERR
Sub fpadd_aux
(fac1
As decfloat
, fac2
As decfloat
) c = 0
v
= CVL(Mid$(fac2.mantissa
, 4 * i
+ 1, 4)) + CVL(Mid$(fac1.mantissa
, 4 * i
+ 1, 4)) + c
v = v - 1000000000
c = 1
c = 0
Mid$(fac1.mantissa
, 4 * i
+ 1, 4) = MKL$(v
) v
= CVL(Mid$(fac1.mantissa
, 4 * 0 + 1, 4)) + CVL(Mid$(fac2.mantissa
, 4 * 0 + 1, 4)) + c
Mid$(fac1.mantissa
, 4 * 0 + 1, 4) = MKL$(v
)
er = NORM_FAC1%(fac1)
Sub fpsub_aux
(fac1
As decfloat
, fac2
As decfloat
) c = 0
v
= CVL(Mid$(fac1.mantissa
, 4 * i
+ 1, 4)) - CVL(Mid$(fac2.mantissa
, 4 * i
+ 1, 4)) - c
v = v + 1000000000
c = 1
c = 0
Mid$(fac1.mantissa
, 4 * i
+ 1, 4) = MKL$(v
) v
= CVL(Mid$(fac1.mantissa
, 4 * 0 + 1, 4)) - CVL(Mid$(fac2.mantissa
, 4 * 0 + 1, 4)) - c
Mid$(fac1.mantissa
, 4 * 0 + 1, 4) = MKL$(v
)
c = NORM_FAC1(fac1)
Sub fpadd
(result
As decfloat
, x
As decfloat
, y
As decfloat
)
Dim As decfloat fac1
, fac2
xsign = x.sign: x.sign = 0
ysign = y.sign: y.sign = 0
c = cmp(x, y)
x.sign = xsign
y.sign = ysign
fac1 = y
fac2 = x
fac1 = x
fac2 = y
t = fac1.exponent - fac2.exponent
'The difference between the two
'exponents indicate how many times
'we have to multiply the mantissa
'of FAC2 by 10 (i.e., shift it right 1 place).
'If we have to shift more times than
'we have digits, the result is already in FAC1.
t = fac1.exponent - fac2.exponent
t = t - 1
'See if the signs of the two numbers
'are the same. If so, add; if not, subtract.
If fac1.sign
= fac2.sign
Then 'add Call fpadd_aux
(fac1
, fac2
) Call fpsub_aux
(fac1
, fac2
) result = fac1
Sub fpsub
(result
As decfloat
, x
As decfloat
, y
As decfloat
) Dim As decfloat fac1
, fac2
fac1 = x
fac2 = y
fac2.sign
= fac2.sign
Xor &H8000 Call fpadd
(result
, fac1
, fac2
)
fac1 = x
'check exponents. if either is zero,
'the result is zero
If fac1.exponent
= 0 Or y
= 0 Then 'result is zero...clear fac1. fac1.sign = 0
fac1.exponent = 0
For count
= 0 To NUM_DWORDS
- 1 Mid$(fac1.mantissa
, 4 * count
+ 1, 4) = MKL$(0) er = NORM_FAC1(fac1)
result = fac1
fac1.sign
= fac1.sign
Xor &H8000 result = fac1
'now determine exponent of result.
'as you do...watch for overflow.
' ex=fac2.exponent-BIAS+fac1.exponent-1
er = EXPO_ERR
'for number of digits in the floating
'point number, add fac2 to fac1 number
'of times given by lowest nibble in
'fac3. then shift fac1 and fac3
'right 1 digit and repeat.
'count=NUM_DIGITS-1
carry = 0
prod
= CVL(Mid$(fac1.mantissa
, 4 * i
+ 1, 4)) prod = digit * prod + carry
value
= (prod
Mod 1000000000) Mid$(fac1.mantissa
, 4 * i
+ 1, 4) = MKL$(value
) carry = prod \ 1000000000
fac1.exponent = fac1.exponent + 1
Mid$(fac1.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(fac1.mantissa
, 4 * 0 + 1, 4)) + carry
* 100000000) fac1.exponent = fac1.exponent + 2
Mid$(fac1.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(fac1.mantissa
, 4 * 0 + 1, 4)) + carry
* 10000000) fac1.exponent = fac1.exponent + 3
Mid$(fac1.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(fac1.mantissa
, 4 * 0 + 1, 4)) + carry
* 1000000) fac1.exponent = fac1.exponent + 4
Mid$(fac1.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(fac1.mantissa
, 4 * 0 + 1, 4)) + carry
* 100000) fac1.exponent = fac1.exponent + 5
Mid$(fac1.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(fac1.mantissa
, 4 * 0 + 1, 4)) + carry
* 10000) fac1.exponent = fac1.exponent + 6
Mid$(fac1.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(fac1.mantissa
, 4 * 0 + 1, 4)) + carry
* 1000) fac1.exponent = fac1.exponent + 7
Mid$(fac1.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(fac1.mantissa
, 4 * 0 + 1, 4)) + carry
* 100) fac1.exponent = fac1.exponent + 8
Mid$(fac1.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(fac1.mantissa
, 4 * 0 + 1, 4)) + carry
* 10) fac1.exponent = fac1.exponent + 9
Mid$(fac1.mantissa
, 4 * 0 + 1, 4) = MKL$(CVL(Mid$(fac1.mantissa
, 4 * 0 + 1, 4)) + carry
)
'fac1.exponent=fac2.exponent+fac1.exponent-BIAS-1
er = NORM_FAC1(fac1)
'fac1.exponent+=c 'ex
'if v>100000000 then fac1.exponent+=1
fac1.sign
= fac1.sign
Xor &H8000 result = fac1
Sub fpmul
(result
As decfloat
, x
As decfloat
, y
As decfloat
) Dim As decfloat fac1
, fac2
, fac3
fac1 = x
fac2 = y
'check exponents. if either is zero,
'the result is zero
If fac1.exponent
= 0 Or fac2.exponent
= 0 Then 'result is zero...clear fac1. fac1.sign = 0
fac1.exponent = 0
For i
= 0 To NUM_DWORDS
- 1 Mid$(fac1.mantissa
, 4 * i
+ 1, 4) = MKL$(0) er = NORM_FAC1(fac1)
result = fac1
'now determine exponent of result.
'as you do...watch for overflow.
ex = fac2.exponent - BIAS + fac1.exponent
er = EXPO_ERR
fac1.exponent = ex
'determine the sign of the product
fac1.sign
= fac1.sign
Xor fac2.sign
'copy fac1 mantissa to fac3 and clear fac1's mantissa
For i
= 0 To NUM_DWORDS
- 1 Mid$(fac3.mantissa
, 4 * i
+ 1, 4) = MKL$(0) Mid$(fac1.mantissa
, 4 * i
+ 1, 4) = MKL$(0) 'for number of digits in the floating
'point number, add fac2 to fac1 number
'of times given by lowest nibble in
'fac3. then shift fac1 and fac3
'right 1 digit and repeat.
carry = 0
digit
= CVL(Mid$(y.mantissa
, 4 * j
+ 1, 4)) prod
= digit
* CVL(Mid$(x.mantissa
, 4 * i
+ 1, 4)) + carry
Mid$(fac3.mantissa
, 4 * i
+ 1, 4) = MKL$(prod
Mod 1000000000) carry = prod \ 1000000000
Mid$(fac3.mantissa
, 4 * 0 + 1, 4) = MKL$(carry
)
c = 0
v
= CVL(Mid$(fac3.mantissa
, 4 * i
+ 1, 4)) + CVL(Mid$(fac1.mantissa
, 4 * i
+ 1, 4)) + c
v = v - 1000000000
c = 1
c = 0
Mid$(fac1.mantissa
, 4 * i
+ 1, 4) = MKL$(v
) v
= CVL(Mid$(fac1.mantissa
, 4 * 0 + 1, 4)) + CVL(Mid$(fac3.mantissa
, 4 * 0 + 1, 4)) + c
Mid$(fac1.mantissa
, 4 * 0 + 1, 4) = MKL$(v
)
er = NORM_FAC1(fac1)
result = fac1
Sub recip
(result
As decfloat
, n
As decfloat
) Dim As decfloat r
, r2
, two
l
= Log(NUM_DIGITS
* 0.0625) * 1.5 result = r
x = 1# / x
result = r