Files
uiua-bigint/main.ua
2025-09-30 10:16:54 +02:00

22 lines
554 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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
└─╴