10 releases
0.1.1 | May 30, 2024 |
---|---|
0.1.0 | Jul 7, 2022 |
0.1.0-a8 | Oct 16, 2021 |
0.1.0-a2 | Sep 6, 2021 |
#292 in Math
35KB
990 lines
Dual Balanced Ternary Arithmetic
Migrated from https://github.com/dual-balanced-ternary/dual-balanced-ternary.nim
Usages
use dual_balanced_ternary::{ternary};
ternary("&1.1")
Development
cargo test
cargo run --example buffer
Notice, current buffer format is not compact, but conceptually:
[integral length]+[integral pairs]+[fractional pairs]
since a dbt digits pair takes 81
and u8
takes 256
, 2/3
of spaces are wasted.
License
MIT
lib.rs
:
- Dual Balanced Ternary Arithmetic
Dual balanced ternary(DBT) is an extension to balanced ternary in 2D space.
Unit values of DBT is has a layout like a magic square, where 1
is the front direction.
6 1 8
7 5 3
2 9 4
At a bigger scale, the layout of the magic square repeats, which leads to &11
and &19
like in decimals.
&
in this case is a special mark indicating it's a DBT value.
There are some interesting features for the basic math:
= (* &1 &1) &1
= (* &1 &9) &9
= (* &9 &9) &1
= (* &3 &3) &9
and:
= (+ &1 &3) &8
= (+ &1 &1) &19
= (* &3 &7) &5
The math is roughly equal to Complex numbers, expect for that its identity value is 1
pointing at at front.