10-09-2022, 05:09 PM
Hi Jack,
Bit shifting is something I haven't made familiar to me. What is familiar to me is optimization large routines. Since you are getting into lots of lines of code, would this modification be of any benefit to you?
Swap out IF/THEN routines like this...
With an algorithm like this...
Example of number output...
The flip side is the longer method is easier to read through, but for speed sake, the algorithm would be faster than running through all the those conditional statements.
Sorry I couldn't test my code out in the routine; what you are doing is a bit flipping beyond me. I think I code it correctly, but if you want to use the idea, please test it yourself. I wouldn't want to set back your progress.
Thanks for all your help with my iteration routines. You really have some mad math skills!
Pete
Bit shifting is something I haven't made familiar to me. What is familiar to me is optimization large routines. Since you are getting into lots of lines of code, would this modification be of any benefit to you?
Swap out IF/THEN routines like this...
Code: (Select All)
If carry = 0 Then
LSHIFT_n result, 9
result.exponent = result.exponent - 9
result.M6 = result.M6 + quotient
ElseIf carry < 10 Then
LSHIFT_n result, 8
result.exponent = result.exponent - 8
result.M6 = result.M6 + quotient \ 10
ElseIf carry < 100 Then
LSHIFT_n result, 7
result.exponent = result.exponent - 7
result.M6 = result.M6 + quotient \ 100
ElseIf carry < 1000 Then
LSHIFT_n result, 6
result.exponent = result.exponent - 6
result.M6 = result.M6 + quotient \ 1000
ElseIf carry < 10000 Then
LSHIFT_n result, 5
result.exponent = result.exponent - 5
result.M6 = result.M6 + quotient \ 10000
ElseIf carry < 100000 Then
LSHIFT_n result, 4
result.exponent = result.exponent - 4
result.M6 = result.M6 + quotient \ 100000
ElseIf carry < 1000000 Then
LSHIFT_n result, 3
result.exponent = result.exponent - 3
result.M6 = result.M6 + quotient \ 1000000
ElseIf carry < 10000000 Then
LSHIFT_n result, 2
result.exponent = result.exponent - 2
result.M6 = result.M6 + quotient \ 10000000
ElseIf carry < 100000000 Then
LSHIFT_n result, 1
result.exponent = result.exponent - 1
result.M6 = result.M6 + quotient \ 100000000
End If
With an algorithm like this...
Code: (Select All)
j& = LEN(LTRIM$(STR$(carry)))
LSHIFT_n result, 10 - j&
result.exponent = result.exponent - 10 - j&
result.M6 = result.M6 + quotient \ carry
Example of number output...
Code: (Select All)
DIM carry AS DOUBLE
FOR i = 0 TO 8
carry = 10 ^ i
j = LEN(LTRIM$(STR$(carry)))
'LSHIFT_n result, 10 - j
PRINT "carry ="; carry;: LOCATE , 27: PRINT "j ="; j, "10 - j ="; 10 - j
result.exponent = result.exponent - 10 - j
result.M6 = result.M6 + quotient \ LEN(LTRIM$(STR$(carry)))
NEXT
The flip side is the longer method is easier to read through, but for speed sake, the algorithm would be faster than running through all the those conditional statements.
Sorry I couldn't test my code out in the routine; what you are doing is a bit flipping beyond me. I think I code it correctly, but if you want to use the idea, please test it yourself. I wouldn't want to set back your progress.
Thanks for all your help with my iteration routines. You really have some mad math skills!
Pete