22 lines
554 B
Plaintext
22 lines
554 B
Plaintext
# bigint
|
||
|
||
# base -- internal representation of number
|
||
β ← 1e9
|
||
|
||
# add two little-endian digital bigints
|
||
# ? b1 b2
|
||
Add ← (
|
||
˜⊂0⬚0+ # fill-add and expand digits
|
||
⍥(+↻¯1⊃(⌊÷)◿β)∞ # carry calc
|
||
⍜⇌(⍥↘₁=0⊸⊢) # trim trailing zeroes
|
||
)
|
||
|
||
# repeated addition of two little-endian digital bigints
|
||
# ? multiplier multiplicand
|
||
Mult ← ⍥Add⌝⊥β ⊙(⊥β0)
|
||
|
||
┌─╴test
|
||
⍤⤙≍ ⊙+◡(⌝⊥β Add ∩(⊥β)) 10000000000000 10000000000000
|
||
⍤⤙≍ ⊙×◡(⌝⊥β Mult ∩(⊥β)) 3 7
|
||
└─╴
|