saxbophone / arby

Arbitrary precision arithmetic in C++, even at compile-time
https://saxbophone.com/arby/
Mozilla Public License 2.0
8 stars 1 forks source link

Get Nat as sequence of bits (and construct from bits) #121

Open saxbophone opened 2 years ago

saxbophone commented 2 years ago
constexpr codlili::List<bool> Nat::bits() const;

constexpr Nat::Nat(const codlili::List<bool>& bits);

template <std::size_t N>
constexpr Nat::Nat(const std::bitset<N>& bits);

We can use std::bitset to take a shortcut when converting to bits (make a bitset for each digit and read bits out of them in sequence).

Related to #83, #114

saxbophone commented 2 years ago

Dropped from v0.5 milestone —if we're going to read bits, we should probably support writing them (via ctor) too, that is too much work for the meagre benefit right now.