implement bigint

This commit is contained in:
2025-09-30 10:16:24 +02:00
parent 33fa6ede42
commit 090d8e5229

21
main.ua Normal file
View File

@@ -0,0 +1,21 @@
# 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
└─╴