Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
b+ String Math Update
#26
It works! from years ago!
Code: (Select All)
Function mult$ (a$, b$) 'assume both positive integers prechecked as all digits strings
    Dim As Long la, lb, m, g, dp
    Dim As _Unsigned _Integer64 v18, sd, co
    Dim f18$, f1$, t$, build$, accum$

    If a$ = "0" Then mult$ = "0": Exit Function
    If b$ = "0" Then mult$ = "0": Exit Function
    If a$ = "1" Then mult$ = b$: Exit Function
    If b$ = "1" Then mult$ = a$: Exit Function
    'find the longer number and make it a mult of 18 to take 18 digits at a time from it
    la = Len(a$): lb = Len(b$)
    If la > lb Then
        m = Int(la / 18) + 1
        f18$ = Right$(String$(m * 18, "0") + a$, m * 18)
        f1$ = b$
    Else
        m = Int(lb / 18) + 1
        f18$ = Right$(String$(m * 18, "0") + b$, m * 18)
        f1$ = a$
    End If
    For dp = Len(f1$) To 1 Step -1 'dp = digit position of the f1$
        build$ = "" 'line builder
        co = 0
        'now taking 18 digits at a time Thanks Steve McNeill
        For g = 1 To m
            v18 = Val(Mid$(f18$, (m - g) * 18 + 1, 18))
            sd = Val(Mid$(f1$, dp, 1))
            t$ = Right$(String$(19, "0") + _Trim$(Str$(v18 * sd + co)), 19)
            co = Val(Mid$(t$, 1, 1))
            build$ = Mid$(t$, 2) + build$
        Next g
        If co Then build$ = _Trim$(Str$(co)) + build$
        If dp = Len(f1$) Then
            accum$ = build$
        Else
            accum$ = add$(accum$, build$ + String$(Len(f1$) - dp, "0"))
        End If
    Next dp
    mult$ = accum$
End Function
b = b + ...
Reply


Messages In This Thread
b+ String Math Update - by bplus - 09-26-2022, 06:01 PM
RE: b+ String Math Update - by Pete - 09-26-2022, 06:27 PM
RE: b+ String Math Update - by bplus - 09-26-2022, 06:38 PM
RE: b+ String Math Update - by Pete - 09-26-2022, 06:53 PM
RE: b+ String Math Update - by vince - 09-29-2022, 03:16 AM
RE: b+ String Math Update - by bplus - 09-29-2022, 09:26 AM
RE: b+ String Math Update - by Pete - 09-29-2022, 07:59 PM
RE: b+ String Math Update - by bplus - 10-01-2022, 05:22 PM
RE: b+ String Math Update - by bplus - 10-01-2022, 05:30 PM
RE: b+ String Math Update - by Pete - 10-01-2022, 06:09 PM
RE: b+ String Math Update - by bplus - 10-01-2022, 06:45 PM
RE: b+ String Math Update - by bplus - 10-02-2022, 01:49 AM
RE: b+ String Math Update - by Kernelpanic - 04-03-2025, 04:14 PM
RE: b+ String Math Update - by Dragoncat - 04-02-2025, 06:29 AM
RE: b+ String Math Update - by bplus - 04-02-2025, 01:35 PM
RE: b+ String Math Update - by SMcNeill - 04-02-2025, 02:02 PM
RE: b+ String Math Update - by Dragoncat - 04-04-2025, 06:42 AM
RE: b+ String Math Update - by SMcNeill - 04-04-2025, 07:28 AM
RE: b+ String Math Update - by bplus - 04-02-2025, 02:26 PM
RE: b+ String Math Update - by SMcNeill - 04-02-2025, 03:11 PM
RE: b+ String Math Update - by Pete - 04-03-2025, 05:02 PM
RE: b+ String Math Update - by SMcNeill - 04-03-2025, 06:12 PM
RE: b+ String Math Update - by Pete - 04-03-2025, 06:18 PM
RE: b+ String Math Update - by SMcNeill - 04-03-2025, 07:24 PM
RE: b+ String Math Update - by Pete - 04-03-2025, 09:43 PM
RE: b+ String Math Update - by SMcNeill - 04-03-2025, 10:11 PM
RE: b+ String Math Update - by Pete - 04-03-2025, 11:49 PM
RE: b+ String Math Update - by bplus - 04-04-2025, 12:40 AM
RE: b+ String Math Update - by Dragoncat - 04-04-2025, 04:53 AM
RE: b+ String Math Update - by Dragoncat - 04-11-2025, 07:02 AM
RE: b+ String Math Update - by Dragoncat - 04-11-2025, 07:27 AM
RE: b+ String Math Update - by bplus - 04-11-2025, 11:56 AM



Users browsing this thread: 1 Guest(s)