Isaac Dupree
unread,Mar 29, 2013, 7:22:01 AM3/29/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to lase...@googlegroups.com
data_structures/bignum.hpp
use bigint<> (signed) or biguint<> (unsigned) with a numeric template
parameter being the number of bits you want (it must be a multiple of
64). For example, bigint<192> is a 192-bit signed two's-complement integer.
All operations are defined-behavior and modulo (behind the scenes,
arithmetic all uses uint64_t because that's the simplest way to do it,
so we get this defined modulo behavior as a side effect).
* Moderately tested (tests/bignum_tests.cpp). Egregious bugs in
add/multiply/subtract squelched, but there may still be some un-found
incorrect results.
* No division operation yet. Has isqrt, ilog2, etc. already. Can
multiply from smaller to bigger int sizes using lossless_multiply() or
multiply_to<number of bits>().
* Works in a physical_quantity; doesn't work in bounds_checked_int yet.
* Has conversion to floating point but not currently from floating point.
* I might have left out something silly because I've only tested it in
test code yet, not real code.
Also: no arbitrary-precision compile-time numbers yet. I think they
will have to be semi-duplicate code with the runtime numbers; this
runtime bignum code has lots of loops and is definitely not constexpr.
-Isaac