15 Commits

Author SHA1 Message Date
Josh Stone
e679836303 Add a RandomBits distribution 2018-05-23 20:57:29 -07:00
Josh Stone
ec181ea593 Update rand CI 2018-05-22 16:56:54 -07:00
Josh Stone
b72822bbde impl SampleUniform for BigInt 2018-05-22 14:59:36 -07:00
Josh Stone
4ef07c4625 impl SampleUniform for BigUint 2018-05-22 14:48:52 -07:00
Josh Stone
39104f5732 refactor tests/rand.rs 2018-05-22 14:38:59 -07:00
Josh Stone
04252b7716 Add basic conversions for i128 and u128 2018-05-15 18:01:14 -07:00
Josh Stone
96c1d69279 Implement assignment operators for BigInt
All of these operators were already implemented for `BigUint`, so
now `BigInt` support the same use.

Closes #7.
2018-05-09 16:36:29 -07:00
Josh Stone
dd4081721f sources shouldn't be executable 2018-05-09 16:18:56 -07:00
Josh Stone
087c4ecfd6 Add serde tests 2018-05-03 12:39:15 -07:00
Josh Stone
a849284320 Remove big_digit::* from the public API
The *idea* of `big_digit` and its type aliases is that we may someday
use something other than `u32` in the representation, perhaps even
different sizes for different targets.  That's still a possibility, but
I think it's not really feasible to expose this variation in the public
API.  Calling `BigUint::from_slice([1, 2, 3])` is only meaningful if you
know what that size is, and users can't really alternate this kind of
thing based on a type definition.  So for now, we just commit to `u32`
units in the public API, no matter what we may do internally.

This removal is a breaking change, part of the 0.2 semver bump.  If I'm
wrong and somebody can show a compelling use case for `big_digit`, we
can always add things back into the public API later.
2018-04-27 23:52:41 -07:00
Trevor Spiteri
e005dcc942 add tests for two's-complement bitwise operations 2018-03-04 10:22:29 +01:00
Josh Stone
8964eb9887 Chop the tests up
The test modules were getting huge, and some of its functions were
actually a huge amount of code due to macros, causing tests to take a
long time just to compile.  They are now separated into a few different
tests, and the scalar macros especially are now expanded more sparingly
in just a few `check()` functions.

Test compile times for me went from about 25 seconds to 1.5s in debug
mode, and from 300 seconds (!) to about 8s in release mode.
2018-02-26 22:13:25 -08:00
Josh Stone
f4cc2abff1 Add BigInt::modpow
This performs modular exponentiation on signed `BigInt`.  The exponent
must be positive, and the modulus must be non-zero.  The implementation
leverages `BigUint::modpow`, fixing the signs as needed afterward.
2018-02-08 13:57:55 -08:00
Alex Crichton
a6a399d52e Enable testing on stable Rust 2015-05-19 09:22:06 -07:00
Erick Tryzelaar
f4a69a6f01 Export the #[derive(FromPrimitive)] from rust proper
This changes the name to #[derive(NumFromPrimitive)]
in order to not conflict with the libsyntax macro.
2015-04-12 11:19:48 -07:00