Commit Graph

731 Commits

Author SHA1 Message Date
Sigurd Kolltveit f138f3da9e Add formatting options for Complex 2017-03-18 16:04:53 +01:00
Vinzent Steinberg c408bd6605 Try to fix build on Rust 1.8 2017-03-17 18:21:06 +01:00
Vinzent Steinberg 8d235759dd Implement an iterator over the binomial coefficients 2017-03-17 18:03:58 +01:00
Vinzent Steinberg ebe3f85976 Implement multinomial 2017-03-17 17:27:46 +01:00
Homu 2adf018aa6 Auto merge of #270 - vks:binomial, r=cuviper
Implement binomial

The implementation avoids overflows and fractions.
2017-03-16 08:55:20 +09:00
Vinzent Steinberg 40cbe1ff20 Use correct formula 2017-03-12 10:23:27 +01:00
Vinzent Steinberg 07df43b034 Address binomial review feedback
* Use substraction instead of division in comparison.
* More tests.
* Add comment.
2017-03-12 10:17:49 +01:00
Vinzent Steinberg 2f6eb31903 Implement binomial
The implementation avoids overflows and fractions.
2017-03-11 16:44:51 +01:00
Josh Stone d23e3f32b8 num-bigint-0.1.37 2017-03-08 11:14:32 -08:00
Homu fe21c725e8 Auto merge of #269 - cuviper:biguint-parse-plus, r=cuviper
bigint: Create the parsing error better for nested `+`

If a `+` is encountered in the middle of parsing a BigUint, this should
generate an `ParseIntError::InvalidDigit`.  Since we can't create that
directly, we get it by trying to parse a `u64` from this point, but of
course `+` is a perfectly valid prefix to a `u64`.

Now we include the previous character in the string passed to `u64`, so it
has proper parsing context to understand what's in error.

Fixes #268.
2017-03-09 04:10:48 +09:00
Josh Stone 0b6cae0dc7 bigint: Create the parsing error better for nested `+`
If a `+` is encountered in the middle of parsing a BigUint, this should
generate an `ParseIntError::InvalidDigit`.  Since we can't create that
directly, we get it by trying to parse a `u64` from this point, but of
course `+` is a perfectly valid prefix to a `u64`.

Now we include the previous character in the string passed to `u64`, so
it has proper parsing context to understand what's in error.

Fixes #268.
2017-03-06 13:23:40 -08:00
Josh Stone 4b8c71fbec bigint: Cleanup unused imports 2017-03-06 13:20:30 -08:00
Josh Stone 66ce252494 Bump versions in the num collection 2017-02-26 14:18:33 -08:00
Josh Stone 6632ca8e1b Merge pull request #267 from cuviper/licenses
Add licenses to subcrates
2017-02-26 13:53:29 -08:00
Josh Stone 1a66ee9e80 Add licenses to subcrates 2017-02-26 13:39:23 -08:00
Homu d273495cbf Auto merge of #263 - cuviper:revamp-ci, r=hauleth
Bump rustc to 1.8 and revamp all CI

This bumps the minimum rustc to 1.8.0, "fixing" #257.  I normally
consider this a breaking change, but we were already broken due to
external factors, for which I couldn't find a workaround.

This adds 1.15.0 to the CI matrix to build stable num-derive.  We still
need nightly to run its tests though, because of compiletest_rs, and
dev-dependencies can't be optional.

The testing scripts are moved from .travis/ to ci/, as they don't really
need to be hidden.  It's also now consolidated into one test_full.sh
which considers $TRAVIS_RUST_VERSION as needed.
2017-02-10 09:19:34 +09:00
Josh Stone 1606fe7206 Bump rustc to 1.8 and revamp all CI
This bumps the minimum rustc to 1.8.0, "fixing" #257.  I normally
consider this a breaking change, but we were already broken due to
external factors, for which I couldn't find a workaround.

This adds 1.15.0 to the CI matrix to build stable num-derive.  We still
need nightly to run its tests though, because of compiletest_rs, and
dev-dependencies can't be optional.

The testing scripts are moved from .travis/ to ci/, as they don't really
need to be hidden.  It's also now consolidated into one test_full.sh
which considers $TRAVIS_RUST_VERSION as needed.
2017-02-09 16:09:48 -08:00
Josh Stone d561e4b702 Merge pull request #262 from Xaeroxe23/master
Add clamp function
2017-02-09 14:17:14 -08:00
Jacob Kiesel c78a48fd35 Improve documentation comments
Remove passive voice from documentation comments.
2017-02-08 15:10:01 -07:00
Jacob Kiesel 17665ec50d Update lib.rs
Make assert debug error more accurate.
2017-02-07 15:03:00 -07:00
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
Josh Stone 817ab00f64 Merge pull request #256 from nwin/add-wrapping-traits
Added traits for wrapping arithmetics.
2017-02-04 21:47:53 -08:00
nwin 58b7da46d2 Added tests. 2017-02-04 10:42:12 +01:00
Josh Stone ba54797d60 Merge pull request #258 from frewsxcv/patch-1
Add doc example for `num_traits::Num::from_str_radix`.
2017-01-31 09:37:30 -08:00
Corey Farwell 19109883de Add doc example for `num_traits::Num::from_str_radix`. 2017-01-30 23:42:27 -05:00
nwin 450c0e2760 Correct typos. 2017-01-26 21:12:27 +01:00
nwin ee9d474243 Ensure compatibility with Rust 1.0.0. 2017-01-22 10:13:50 +01:00
nwin d25f53056d Added traits for wrapping arithmetics.
Added `Wrapping` traits for the most common operations. Similar to the already present `Checked` traits.
2017-01-22 09:45:35 +01:00
Josh Stone 74f1e26f62 macros: bump to 0.1.37 2017-01-11 16:52:06 -08:00
Josh Stone 75372c0639 derive: bump to 0.1.39 2017-01-11 16:51:14 -08:00
Homu bda31b1a33 Auto merge of #252 - est31:master, r=cuviper
macros 1.1 is now stable

Fixes #251. Also includes a patch to get the tests working again.
2017-01-08 08:14:45 +09:00
est31 9aced4066e derive: custom derive is now stable 2017-01-07 23:51:55 +01:00
est31 c742cf9aec derive: use latest compiletest_rs crate
Version 2.2 was not compiling any more: https://github.com/laumann/compiletest-rs/issues/51
2017-01-07 23:51:21 +01:00
Homu a4faeeffc4 Auto merge of #250 - andersk:should_panic, r=cuviper
rational: test_recip_fail: Correct should_panic syntax

Fixes this warning with rustc nightly:

```
warning: attribute must be of the form: `#[should_panic]` or `#[should_panic(expected = "error message")]`
    --> rational/src/lib.rs:1051:7
     |
1051 |     #[should_panic = "== 0"]
     |       ^^^^^^^^^^^^^^^^^^^^^
     |
     = note: Errors in this attribute were erroneously allowed and will become a hard error in a future release.
```
2017-01-07 06:26:59 +09:00
Anders Kaseorg fd44a86866 rational: test_recip_fail: Correct should_panic syntax
Fixes this warning:

warning: attribute must be of the form: `#[should_panic]` or `#[should_panic(expected = "error message")]`
    --> rational/src/lib.rs:1051:7
     |
1051 |     #[should_panic = "== 0"]
     |       ^^^^^^^^^^^^^^^^^^^^^
     |
     = note: Errors in this attribute were erroneously allowed and will become a hard error in a future release.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2017-01-06 15:05:01 -05:00
Homu d468177eee Auto merge of #248 - dnsl48:ratio_into_pair, r=cuviper
rational: Into<(T,T)> implementation

Right now it appears impossible to get integers without cloning them. Converting into a pair can be a cheap and easy way to extract the data.
2016-12-10 09:47:59 +09:00
dnsl48 9d7ab663b1 From<(T,T)> implementation 2016-12-10 09:19:02 +13:00
dnsl48 70da35dff5 Into<(T,T)> implementation 2016-12-10 08:39:06 +13:00
Homu 7db32a4ecd Auto merge of #246 - cuviper:complex-eq, r=hauleth
complex: derive Eq

Fixes #245.
2016-12-06 18:48:42 +09:00
Josh Stone 5531031252 complex: derive Eq
Fixes #245.
2016-12-05 23:11:40 -08:00
Homu dc8c8fc3f6 Auto merge of #244 - wictory:master, r=cuviper
Added trait From<T> for Ratio<T> where T: Clone + Integer

Hi!

So I thought that this kind of trait would be useful when one wants to write code which should be generic over different types of numbers.
2016-12-03 07:14:51 +09:00
Homu a63bbc916f Auto merge of #243 - cuviper:intern-macros, r=hauleth
macros: update string interning

None
2016-12-03 07:08:30 +09:00
Wictor Lund 4bdad38eee Added test for trait From<T> for Ratio<T> where T: Clone + Integer. 2016-12-01 22:07:03 +02:00
Wictor Lund de91d5d9e3 Added trait From<T> for Ratio<T> where T: Clone + Integer 2016-12-01 21:38:53 +02:00
Josh Stone be61427d03 derive: bump to 0.1.38 2016-11-28 09:46:18 -08:00