Commit Graph

182 Commits

Author SHA1 Message Date
Jacob Kiesel f8dcec366b Made requested changes. 2017-02-07 13:02:32 -07:00
Jacob Kiesel 182e08a091 Add inline attribute 2017-02-07 10:49:28 -07:00
Jacob Kiesel b346f9c2df Add a new line for improved formatting. 2017-02-07 10:18:23 -07:00
Jacob Kiesel a5445b7619 Adding documentation comments 2017-02-07 10:18:23 -07:00
Jacob Kiesel 07ff5b62b9 Changing to >= and <= as it's a slight optimization 2017-02-07 09:52:23 -07:00
Jacob Kiesel 28633b7e6d Add clamp function 2017-02-07 09:48:34 -07:00
bluss ff2a350e98 Use the integer32 playground 2016-11-02 19:51:10 +01:00
bluss e4a6956e5a Add doc(html_root_url) and other doc attrs to each crate
Also update to use https instead of http. This avois mixed content
degradation on docs.rs.

The doc root URLs are correct as they are, the URL does not include the
crate name itself.
2016-11-01 02:14:23 +01:00
Vinzent Steinberg 3e4595eac6 Move functions remaining in num to num-traits
Fixes #102.
2016-05-13 10:38:14 +02:00
Josh Stone 865c491ce2 num: remove `pub` from sub-crates
Rust 1.4 through 1.7 will issue warnings that `pub extern crate` does
not work as expected, although it appears to be fine.  But Rust 1.8 and
later issue `#[warn(private_in_public)]` for `pub use num_foo as foo` if
that crate isn't public, and that's headed toward a hard error.

@bluss suggested instead `pub mod foo { pub use num_foo::*; }`, which
I thought I had tried before, but it appears to work fine on all
versions of Rust.  Let's do it!

A small downside is that docs for `num::foo` now just show the wildcard
reexport, instead of direct documentation, but at least there's a link
to follow to the sub-crate.

It's a breaking change that `num::num_foo` paths are no longer public,
but we didn't really want those exposed in the first place.  I consider
this minor -- people should either use the `num::foo` module as before
the split-up, or use the `num_foo` crate directly.

Fixes #189.
2016-04-29 15:36:17 -07:00
Łukasz Jan Niemier 58b5fe5883 Serializers dependencies 2016-04-11 20:43:07 +02:00
Josh Stone c9d82acf00 test_features.sh: re-enable as a simple build 2016-03-25 18:30:27 -07:00
Josh Stone 9d439e7860 num: don't need std::hash even for testing 2016-03-25 17:50:51 -07:00
Josh Stone 529d7634dd num: use original num_foo crate names for imports
Rust 1.0.0 can't seem to find `foo::bar` imports from renamed crates like
`pub use num_foo as foo`.  Use `num_foo::bar` instead.
2016-03-25 17:50:38 -07:00
Łukasz Jan Niemier b962e2b708 Remove leftovers 2016-03-25 12:40:34 +01:00
Łukasz Jan Niemier 96e9166b0a Extract iter 2016-03-11 01:06:37 +01:00
Łukasz Jan Niemier ed076070e6 Extract complex 2016-03-11 01:06:37 +01:00
Łukasz Jan Niemier 2a67a5b86e Extract num-rational 2016-03-11 01:06:37 +01:00
Łukasz Jan Niemier 54685c46a1 Extract rational 2016-03-11 01:06:37 +01:00
Łukasz Jan Niemier 2176b7048c Extract bigint 2016-03-11 01:06:05 +01:00
Łukasz Jan Niemier f1a80857ee Extract integer module 2016-03-11 01:06:05 +01:00
Łukasz Jan Niemier c124be549f Move traits to separate crate 2016-03-11 01:06:05 +01:00
Murarth df34563eda Expose `BigUint::bits` through `BigInt` 2016-03-05 13:46:22 -07:00
Erick Tryzelaar 112923eec5 Add support for Serde 0.7.
Serde 0.7 dropped it's dependency on num, so this patch moves
the implementations here. For the sake of a better implementation,
this just serializes BigUint as a `Vec<u32>`, `BigInt` as a
`(u8, Vec<u32>)`, `Complex<T>` as a `(T, T)`, and `Ratio<T>`
as a `(T, T)`.
2016-02-27 00:07:32 -08:00
Josh Stone 4e66bbe6a7 Avoid overflows in Ratio's Ord::cmp
Fixes #7
2016-02-22 18:10:29 -08:00
Josh Stone 8be7e7bab5 Simplify some Ratio methods 2016-02-22 18:09:21 -08:00
Josh Stone 5b2cb8df97 Simplify Integer dependant traits
- Integer only needs to require Ord explicitly, and then PartialOrd, Eq,
  and PartialEq come transitively.
- Generics on Integer can implicitly use all of those comparison traits.

This should not be a breaking change, as it doesn't actually change any
effective trait requirements -- only what's explicit for simplicity.
2016-02-22 15:34:10 -08:00
Mike MacDonald (crazymykl) 9def836603 Allow unary `+` when parsing BigInt from strings 2016-02-21 18:09:56 -05:00
Felix S. Klock II d298262573 Reorder ops in LCM to avoid overflow. Fix #166 2016-02-18 22:49:34 +01:00
Josh Stone ebed6756de impl Debug for ParseFloatError
Fixes #165.
2016-02-16 15:37:06 -08:00
Josh Stone 9b2116d78f Fix spelling of "occurred". 2016-02-05 16:04:34 -08:00
est31 3c5ecdc636 Add checked_pow function 2016-02-03 06:43:40 +01:00
Josh Stone afee4e4662 Change PrimInt shift names to signed/unsigned 2016-01-28 22:37:18 -08:00
Josh Stone d798bd4fb8 Add arithmetic/logical shifts to PrimInt 2016-01-27 23:30:33 -08:00
Josh Stone b454a14bc4 bigint: avoid new allocations for small shifts
Before:
    test shl               ... bench:       7,312 ns/iter (+/- 218)
    test shr               ... bench:       5,282 ns/iter (+/- 243)

After:
    test shl               ... bench:       4,946 ns/iter (+/- 88)
    test shr               ... bench:       4,121 ns/iter (+/- 52)
2016-01-27 23:08:47 -08:00
Oliver Middleton 95d8ccdb24 bigint: Make fmt traits take into account formatting parameters 2016-01-22 00:35:35 +00:00
Colin Davidson 3c7441ab0a Add Binary, Octal to BigUint. Add UpperHex, LowerHex, Binary, Octal to BigInt 2016-01-18 21:19:21 -08:00
Colin Davidson a89a2e82e6 Fix test names
Upper and Lower test names were swapped
2016-01-17 12:17:52 -08:00
Colin Davidson d5d7c855b0 Add tests for UpperHex and LowerHex 2016-01-17 12:13:45 -08:00
Colin Davidson 04000436b1 Switch to ascii uppercase function 2016-01-16 22:27:56 -08:00
Colin Davidson 80c4d01b7f Add LowerHex and UpperHex formatting 2016-01-16 21:52:47 -08:00
Alex Burka 5962dd29c9 remove stale #[deriving(Zero)] docs
Fixes #156.
2016-01-15 13:29:34 -05:00
Homu e65fd4e5b2 Auto merge of #150 - ollie27:bigint_to_str, r=cuviper
bigint: small to_str_radix optimization

Before:
```
test fac_to_string     ... bench:       1,630 ns/iter (+/- 34)
test fib_to_string     ... bench:         359 ns/iter (+/- 11)
test to_str_radix_02   ... bench:       3,097 ns/iter (+/- 19)
test to_str_radix_08   ... bench:       1,146 ns/iter (+/- 38)
test to_str_radix_10   ... bench:       4,248 ns/iter (+/- 36)
test to_str_radix_16   ... bench:         881 ns/iter (+/- 44)
test to_str_radix_36   ... bench:       8,073 ns/iter (+/- 75)
```
After:
```
test fac_to_string     ... bench:       1,492 ns/iter (+/- 20)
test fib_to_string     ... bench:         368 ns/iter (+/- 7)
test to_str_radix_02   ... bench:       2,038 ns/iter (+/- 47)
test to_str_radix_08   ... bench:         812 ns/iter (+/- 9)
test to_str_radix_10   ... bench:       3,919 ns/iter (+/- 40)
test to_str_radix_16   ... bench:         703 ns/iter (+/- 58)
test to_str_radix_36   ... bench:       7,852 ns/iter (+/- 81)
```
2016-01-13 08:59:01 +09:00
Brian Smith 9e3e8552ac Make `rand` and `rustc-serialize` dependencies optional.
Previously, the `rand` and `rustc-serialize` dependencies were optional
except they were required for the `bigint` feature.

Make the dependency on the `rand` crate optional in all cases.
including when the `bigint` feature is selected. Some of the tests for
the bigint feature are randomized so, while `rand` is now an optional
dependency, it is a non-optional dev-dependency.

Similarly, make the dependency on the `rustc-serialize` crate optional
in all cases, including when the `bigint` feature is selected.
2016-01-07 16:30:50 -10:00
Josh Stone 22722ac55d pow: shift exp powers of 2 before accumulating
We can save a multiplication if we start the accumulation basically at
the first set bit of the exponent, rather than starting at one and
waiting to multiply.  We only need one itself if the exponent is zero,
which is easy to pre-check.

Before:
    test pow_bench         ... bench:   8,267,370 ns/iter (+/- 93,319)

After:
    test pow_bench         ... bench:   7,506,463 ns/iter (+/- 116,311)
2016-01-06 18:32:01 -08:00
Oliver Middleton d2b23d0f29 bigint: small to_str_radix optimization
Before:

test fac_to_string     ... bench:       1,630 ns/iter (+/- 34)
test fib_to_string     ... bench:         359 ns/iter (+/- 11)
test to_str_radix_02   ... bench:       3,097 ns/iter (+/- 19)
test to_str_radix_08   ... bench:       1,146 ns/iter (+/- 38)
test to_str_radix_10   ... bench:       4,248 ns/iter (+/- 36)
test to_str_radix_16   ... bench:         881 ns/iter (+/- 44)
test to_str_radix_36   ... bench:       8,073 ns/iter (+/- 75)

After:

test fac_to_string     ... bench:       1,492 ns/iter (+/- 20)
test fib_to_string     ... bench:         368 ns/iter (+/- 7)
test to_str_radix_02   ... bench:       2,038 ns/iter (+/- 47)
test to_str_radix_08   ... bench:         812 ns/iter (+/- 9)
test to_str_radix_10   ... bench:       3,919 ns/iter (+/- 40)
test to_str_radix_16   ... bench:         703 ns/iter (+/- 58)
test to_str_radix_36   ... bench:       7,852 ns/iter (+/- 81)
2016-01-05 18:01:12 +00:00
Łukasz Jan Niemier 8e267ee4cb Fix docs and function position 2015-12-30 10:57:54 +01:00
Łukasz Jan Niemier 458e9594d4 Add complex `i` constant function 2015-12-29 16:36:08 +01:00
Oliver Middleton 2c235d2dde bigint: cleanup float conversions 2015-12-24 18:15:56 +00:00
Oliver Middleton a480c7ca6c bigint: fix float conversions
The default implementations of to_f32, to_f64, from_32 and from_f64 are
limited to numbers fitting in i64 but BigInt can of course be much bigger.
The default to_f32 also has double rounding.
from_f32 and from_f64 have undefined behaviour if the float is too big to
fit in an i64.

This fixes these issues and keeps the rounding consistant with other float
to int conversions.

Also add ToBigUint and ToBigInt implementations for f32 and f64.
2015-12-23 07:30:40 +00:00