decfloat -- again
#23
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...

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
Reply


Messages In This Thread
decfloat -- again - by Jack - 09-13-2022, 08:45 PM
RE: decfloat -- again - by Jack - 09-13-2022, 08:48 PM
RE: decfloat -- again - by Jack - 09-14-2022, 02:52 PM
RE: decfloat -- again - by Pete - 09-14-2022, 04:10 PM
RE: decfloat -- again - by SpriggsySpriggs - 09-14-2022, 04:31 PM
RE: decfloat -- again - by Jack - 09-14-2022, 06:26 PM
RE: decfloat -- again - by SpriggsySpriggs - 09-14-2022, 09:30 PM
RE: decfloat -- again - by Pete - 09-14-2022, 07:57 PM
RE: decfloat -- again - by BSpinoza - 09-15-2022, 03:27 AM
RE: decfloat -- again - by Pete - 09-15-2022, 03:37 AM
RE: decfloat -- again - by SpriggsySpriggs - 09-15-2022, 01:56 PM
RE: decfloat -- again - by Jack - 09-16-2022, 09:03 PM
RE: decfloat -- again - by Pete - 09-16-2022, 10:31 PM
RE: decfloat -- again - by Jack - 09-17-2022, 12:19 AM
RE: decfloat -- again - by Pete - 09-17-2022, 12:40 AM
RE: decfloat -- again - by Jack - 09-19-2022, 01:48 AM
RE: decfloat -- again - by Pete - 09-20-2022, 02:30 AM
RE: decfloat -- again - by SpriggsySpriggs - 09-19-2022, 01:08 PM
RE: decfloat -- again - by Jack - 09-20-2022, 12:18 PM
RE: decfloat -- again - by Pete - 09-20-2022, 07:02 PM
RE: decfloat -- again - by Kernelpanic - 09-20-2022, 09:54 PM
RE: decfloat -- again - by Jack - 10-08-2022, 05:51 PM
RE: decfloat -- again - by Pete - 10-09-2022, 05:09 PM
RE: decfloat -- again - by Jack - 10-09-2022, 07:21 PM
RE: decfloat -- again - by Jack - 10-12-2022, 01:00 AM
RE: decfloat -- again - by Pete - 10-12-2022, 01:33 AM
RE: decfloat -- again - by Jack - 10-12-2022, 01:43 AM
RE: decfloat -- again - by Pete - 10-12-2022, 02:12 AM
RE: decfloat -- again - by Jack - 10-14-2022, 12:04 AM
RE: decfloat -- again - by Pete - 10-14-2022, 02:55 AM
RE: decfloat -- again - by Jack - 10-14-2022, 11:32 AM
RE: decfloat -- again - by Jack - 10-14-2022, 01:41 PM
RE: decfloat -- again - by Pete - 10-14-2022, 06:36 PM
RE: decfloat -- again - by Jack - 10-14-2022, 08:09 PM
RE: decfloat -- again - by Pete - 10-14-2022, 08:20 PM
RE: decfloat -- again - by Jack - 10-14-2022, 08:28 PM
RE: decfloat -- again - by Pete - 10-14-2022, 08:45 PM
RE: decfloat -- again - by Jack - 10-14-2022, 08:56 PM
RE: decfloat -- again - by Pete - 10-14-2022, 09:06 PM
RE: decfloat -- again - by Jack - 10-25-2022, 10:32 PM
RE: decfloat -- again - by Pete - 10-25-2022, 10:56 PM



Users browsing this thread: 24 Guest(s)