Kent Overstreet
fa372e230b
Multiply/divide torture test
2015-12-10 15:28:01 -09:00
Kent Overstreet
79928b3185
Improve division performance
...
Before:
test divide_0 ... bench: 4,058 ns/iter (+/- 255)
test divide_1 ... bench: 304,507 ns/iter (+/- 28,063)
test divide_2 ... bench: 668,293,969 ns/iter (+/- 25,383,239)
After:
test divide_0 ... bench: 874 ns/iter (+/- 71)
test divide_1 ... bench: 16,641 ns/iter (+/- 1,205)
test divide_2 ... bench: 1,336,888 ns/iter (+/- 77,450)
2015-12-10 15:25:56 -09:00
Kent Overstreet
08b0022aab
Improve multiply performance
...
The main idea here is to do as much as possible with slices, instead of
allocating new BigUints (= heap allocations).
Current performance:
multiply_0: 10,507 ns/iter (+/- 987)
multiply_1: 2,788,734 ns/iter (+/- 100,079)
multiply_2: 69,923,515 ns/iter (+/- 4,550,902)
After this patch, we get:
multiply_0: 364 ns/iter (+/- 62)
multiply_1: 34,085 ns/iter (+/- 1,179)
multiply_2: 3,753,883 ns/iter (+/- 46,876)
2015-12-10 15:25:42 -09:00
Kent Overstreet
496ae0337c
Add add/subtract functions that work in place, on slices
...
This is needed for the multiply optimizations in the next patch.
2015-12-10 12:33:28 -09:00
Josh Stone
e41016975f
bigint: expand op tests to cover all val/ref combinations
2015-11-16 11:06:39 -08:00
Josh Stone
978d14aa56
bigint: refactor BigInt ops
...
Try to let the underlying BigUint op implement val/ref forwarding as
much as possible, to reduce cloning.
2015-11-16 11:04:41 -08:00
Josh Stone
ce3d375b21
bigint: refactor BigUint ops
...
As much as possible, ops are forwarded to val-ref so the LHS memory can
be reused for the result. This reduces the number of clones required.
2015-11-16 10:56:30 -08:00
Josh Stone
7781256041
bigint: use a simple let-Some-pop to truncate zeros
2015-11-16 10:20:42 -08:00
Murarth
786541bd24
Improve `to_str_radix` implementation
...
Uses in-place division with `u32` divisor to provide a significant speed
improvement.
2015-11-09 13:50:25 -07:00
Josh Stone
642787fbd2
Merge pull request #121 from wrieger93/issue_120
...
Add a function that returns the sign of a BigInt.
2015-10-27 12:13:17 -07:00
David Ripton
e86913924e
Remove extra parentheses to fix a warning
...
Removing extra parentheses in a for loop fixes this warning:
src/bigint.rs:1636:18: 1636:31 warning: unnecessary parentheses around `for` head expression, #[warn(unused_parens)] on by default
2015-10-19 09:43:47 -04:00
William Rieger
1eb3deaca8
Add a function that returns the sign of a BigInt.
2015-10-06 00:32:32 -07:00
Alex Crichton
b57accf314
Update to rust nightly
2015-08-10 12:11:56 -07:00
root
4c123a9e71
Make rustc-serialize, bignum, rational, complex into opt-out features
...
Making bignum optional allows skipping the rustc-serialize and rand
dependencies too, and it makes a big difference in num's build time.
With default (all) features, clean build time including dependencies: 27
seconds.
With no default features, clean build time including dependencies (none):
5 seconds.
2015-06-02 23:48:06 +02:00
Alex Crichton
a6a399d52e
Enable testing on stable Rust
2015-05-19 09:22:06 -07:00
mitchmindtree
f0af39dfae
Removed deprecation attributes that can no longer be used outside of std
2015-04-22 22:27:20 +10:00
Nick Hamann
82aa7c7864
Improve bigint docs.
...
Convert instances of <string literal>.as_bytes() to byte string
literals. Also, add examples for from_bytes_le() and to_bytes_be().
2015-04-15 14:46:07 -05:00
Aaron Turon
63c7a25ed9
Update to 1.0.0-beta (stable only)
...
Along the way, this commit also rationalizes the traits a bit more.
Moving to stable required vendoring a couple of minor things (notably,
radix formatting).
2015-04-03 10:17:39 -07:00
Alex Crichton
fcd3760625
Get tests passing again
2015-04-02 09:37:32 -07:00
Anders Kaseorg
a00fe8b700
Replace FromError with From
...
As per https://github.com/rust-lang/rust/pull/23879 .
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-04-02 06:37:57 -04:00
Alex Crichton
1841c8ace4
Update to rust master
2015-03-29 10:05:02 -07:00
Matt Brubeck
81a16f4a83
rustc-serialize is now rustc_serialize
2015-03-25 17:48:52 -07:00
Alex Crichton
9848257eae
Update to rust master
2015-03-19 09:57:18 -07:00
Joseph Crail
5a0835d5d7
Replace deprecated range function.
2015-03-19 00:15:55 -04:00
Darin Morrison
8ea4c031dd
Replace #[should_fail] with #[should_panic]
2015-03-17 22:21:25 -06:00
Alex Crichton
817dec99aa
Remove usage of deprecated apis
2015-03-04 09:45:19 -08:00
Steve Jahns
fb6b4ae9df
Rust nightly needs explicit cast from u32 to usize
2015-03-04 09:43:44 -07:00
Austin Bonander
f260a7f565
Upgrade to latest Rust
2015-02-20 10:37:11 -08:00
Huon Wilson
2a3f2f060d
Fix test.
2015-02-19 12:46:43 +11:00
Sam Payson
6a0c32782e
Change `radix` to u32, to build with new rustc.
2015-02-18 16:29:46 -08:00
Alex Crichton
e2f0b0d327
Update to rust master
2015-02-05 08:20:16 -08:00
Matt Brubeck
42edb63090
Update FromStr and FromStrRadix to return Result
...
Fixes build errors with Rust 1.0.0-nightly.
2015-02-03 12:31:10 -08:00
Matt Brubeck
b324415930
Change Show to Debug
...
Fixes deprecation warning
2015-02-03 11:05:55 -08:00
Gulshan Singh
7ba31bc3a7
Implemented from_bytes and to_bytes
2015-02-01 20:17:34 -05:00
Alex Crichton
c05cd530db
Bump to 0.1.10
2015-01-23 08:54:55 -08:00
Gulshan Singh
f1bfd76bbb
Fixed some typos and added some examples
2015-01-20 19:25:02 -05:00
Renato Zannon
791264ddfc
Rename BigDigit module to big_digit
...
Without this rename, the library fails to compile on Rust master, since rust-lang/rust#21269 has landed.
2015-01-20 17:17:43 -02:00
Alex Crichton
45f5cc39bd
s/bigusize/biguint/
2015-01-09 13:54:32 -08:00
Huon Wilson
139cf8cf66
Bump to 0.1.7.
2015-01-09 22:36:03 +11:00
Alex Crichton
bfa91ee92a
Bump to 0.1.6
2015-01-07 12:09:44 -08:00
gifnksm
8219095e39
update to rust mater
2015-01-05 01:59:44 +09:00
Sven Nilsen
ae3bb3619c
Upgrade to latest Rust
...
A `_0` test fails, but don’t know why
2015-01-03 19:30:05 +01:00
Alex Crichton
c11ff27994
Update to rust master
2015-01-01 09:07:52 -08:00
Alex Crichton
5d4b921537
Fix build warnings
2014-12-23 09:51:08 -08:00
Zbigniew Siciarz
a006968185
Fix Ordering import
2014-12-23 17:12:57 +01:00
Zbigniew Siciarz
22c50901ff
Convert Result to Option in parse_bytes.
...
`str::from_utf8` changed its return type to `Result`, but
`num::FromStrRadix::from_str_radix` still returns an `Option`. In this case
discarding the `Err` variant with `ok()` seems fine to me.
2014-12-23 17:09:22 +01:00
gifnksm
9316be3bc1
update to latest rustc
2014-12-21 19:41:03 +09:00
Chase McCarthy
a7e9e79049
Add semicolons to macro lines
2014-12-18 21:01:24 -05:00
gifnksm
a325a566c6
update to latest rustc
...
Now, arithmetic binary operator traits take operands by value,
but non-copyable types such as `BigUint` should not always moved out when
applying operators.
This commit implements these operators not only for bare structs also
these references.
By-value implementations are forwarded to by-reference implementations
for now. In the future, by-value implementations may be replaced with
more efficient implementations (for example, the implementation that
reuses moved buffers.)
2014-12-16 23:44:16 +09:00
gifnksm
d89fbbf044
Add `deriving(Copy)` for `Copy`able structs/enums/
2014-12-09 23:46:39 +09:00