-
Notifications
You must be signed in to change notification settings - Fork 0
c8_natural
Dave Hudson edited this page Apr 1, 2017
·
5 revisions
c8::natural
is a class designed to represent the natural numbers (zero and all positive whole numbers). Conceptually they behave in a somewhat similar way to unsigned int
, but offer unlimited precision.
Construct a natural number.
- ~natural
Destroy (and free all resources allocated to) a natural number.
Compare this natural number with another.
Perform arithmetic with this number.
Perform bitwise operations on this number.
Perform assignment operations on this number.
auto count_bits() const noexcept -> unsigned int
auto divide_modulus(natural_digit v) const -> std::pair<natural, natural_digit>
auto divide_modulus(const natural &v) const -> std::pair<natural, natural>
auto gcd(const natural &v) const -> natural
auto to_unsigned_long_long() const -> unsigned long long
auto is_zero() const noexcept -> bool
friend auto operator <<(std::ostream &outstr, const natural &v) -> std::ostream &
TBD
c8::natural allows us to create two large numbers, subtract one from the other, then output the result to std::cout
:
c8::natural s0("5872489572457574027439274027101850990940275827586671651690897");
c8::natural s1("842758978027689671615847509102945571507457514754190754");
auto s2 = s0 - s1;
std::cout << s2;