about summary refs log tree commit diff
path: root/src/libextra/num
AgeCommit message (Collapse)AuthorLines
2014-02-11Factoring bigint, rational, and complex out of libextra into libnum.Felix S. Klock II-3686/+0
Removed use of globs present in earlier versions of modules. Fix tutorial.md to reflect `extra::rational` ==> `num::rational`.
2014-02-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-2/+3
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-02std,extra: remove use of & support for @[].Huon Wilson-1/+1
2014-01-31Fix minor doc typosVirgile Andreani-2/+2
2014-01-30Remove Times traitBrendan Zabarauskas-8/+8
`Times::times` was always a second-class loop because it did not support the `break` and `continue` operations. Its playful appeal was then lost after `do` was disabled for closures. It's time to let this one go.
2014-01-25Uppercase numeric constantsChris Wong-21/+21
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
2014-01-21[std::vec] Rename .last_opt() to .last(), drop the old .last() behaviorSimon Sapin-3/+3
2014-01-21Remove unnecessary parentheses.Huon Wilson-2/+2
2014-01-17Add a generic power functionFlavio Percoco-6/+6
The patch adds a `pow` function for types implementing `One`, `Mul` and `Clone` trait. The patch also renames f32 and f64 pow into powf in order to still have a way to easily have float powers. It uses llvms intrinsics. The pow implementation for all num types uses the exponentiation by square. Fixes bug #11499
2014-01-16Merge Bitwise and BitCount traits and remove from prelude, along with BoundedBrendan Zabarauskas-1/+1
One less trait in std::num, and three less exported in the prelude.
2014-01-09auto merge of #11412 : bjz/rust/num-cleanups, r=alexcrichtonbors-10/+8
The methods contained in `std::num::{Algebraic, Trigonometric, Exponential, Hyperbolic}` have now been moved into `std::num::Real`. This is part of an ongoing effort to simplify `std::num` (see issue #10387). `std::num::RealExt` has also been removed from the prelude because it is not a commonly used trait. r? @alexcrichton
2014-01-09Remove ApproxEq and assert_approx_eq!Brendan Zabarauskas-1/+1
This trait seems to stray too far from the mandate of a standard library as implementations may vary between use cases.
2014-01-09Merge some numeric traits with Real and don't re-export RealExtBrendan Zabarauskas-10/+8
The methods contained in `std::num::{Algebraic, Trigonometric, Exponential, Hyperbolic}` have now been moved into `std::num::Real`. This is part of an ongoing effort to simplify `std::num` (see issue #10387). `std::num::RealExt` has also been removed from the prelude because it is not a commonly used trait.
2014-01-07extratest: Fix all leaked trait importsAlex Crichton-0/+2
2014-01-08Renamed Option::map_default and mutate_default to map_or and mutate_or_setMarvin Löbel-1/+1
2013-12-30Implement Ratio:from_float()Volker Mische-1/+60
The Ratio::from_float() converts a float (f32 and f64) into a Ratio<BigInt>. Closes #9838
2013-12-08Remove dead codesKiet Tran-2/+1
2013-11-26test: Remove all remaining non-procedure uses of `do`.Patrick Walton-4/+12
2013-11-26librustuv: Remove all non-`proc` uses of `do` from `libextra` andPatrick Walton-45/+46
`librustuv`.
2013-11-26Removed unneccessary `_iter` suffixes from various APIsMarvin Löbel-2/+2
2013-11-17extra: handle an edge case in BigUint.to_str().Huon Wilson-1/+6
If any of the digits was one past the maximum (e.g. 10**9 for base 10), then this wasn't detected correctly and so the length of the digit was one more than expected, causing a very large allocation. Fixes #10522. Fixes #10288.
2013-10-24extra: Add getter methods to extra::rational::Ratiogifnksm-0/+66
After merging 0ada7c7, user code have not been able to access to `Ratio`'s numerator and denominator fields. In some algorithms, it is needed to get an rational number's numerator or denominator, but keeping these fields private is necessary for guaranteeing that `Ratio` numbers are irreducible. So, I added the getter methods `numer()` and `denom()`. As a bonus, this commit adds utility methods relating to the ratio-integer conversion.
2013-10-23Removed unnecessary comments and white spaces as suggestedreedlepee-2/+2
2013-10-23Removed Unnecessary comments and white spaces #4386reedlepee-4/+0
2013-10-23Making fields in std and extra : private #4386reedlepee-4/+8
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-10/+10
Who doesn't like a massive renaming?
2013-10-09option: rewrite the API to use compositionDaniel Micay-3/+3
2013-10-05extra: fix BigInt on 32bit machinesErick Tryzelaar-127/+139
2013-10-05extra: Don't truncate {u64,i64} when converting to BigIntsErick Tryzelaar-19/+121
2013-10-02extra: Add ToBigInt and ToBigUint traitsErick Tryzelaar-0/+90
2013-10-02std: Swap {To,From}Primitive to use the 64bit as the unimplemented versionErick Tryzelaar-24/+24
One downside with this current implementation is that since BigInt's default is now 64 bit, we can convert larger BigInt's to a primitive, however the current implementation on 32 bit architectures does not take advantage of this fact.
2013-10-02std: Replace num::IntConvertible with {To,From}PrimitiveErick Tryzelaar-214/+215
2013-10-02auto merge of #9665 : alexcrichton/rust/snapshot, r=brsonbors-1/+1
Uses the new snapshots to kill the old `loop` and introduce the new `continue`.
2013-10-01Migrate users of 'loop' to 'continue'Alex Crichton-1/+1
Closes #9467
2013-10-01remove the `float` typeDaniel Micay-31/+30
It is simply defined as `f64` across every platform right now. A use case hasn't been presented for a `float` type defined as the highest precision floating point type implemented in hardware on the platform. Performance-wise, using the smallest precision correct for the use case greatly saves on cache space and allows for fitting more numbers into SSE/AVX registers. If there was a use case, this could be implemented as simply a type alias or a struct thanks to `#[cfg(...)]`. Closes #6592 The mailing list thread, for reference: https://mail.mozilla.org/pipermail/rust-dev/2013-July/004632.html
2013-09-30extra: Remove usage of fmt!Alex Crichton-16/+16
2013-09-26bigint: backticks for code in documentationkud1ing-35/+35
2013-09-23std: merge rand::{Rng,RngUtil} with default methods.Huon Wilson-1/+1
Also, documentation & general clean-up: - remove `gen_char_from`: better served by `sample` or `choose`. - `gen_bytes` generalised to `gen_vec`. - `gen_int_range`/`gen_uint_range` merged into `gen_integer_range` and made to be properly uniformly distributed. Fixes #8644. Minor adjustments to other functions.
2013-09-18Remove and replace cond! Closes #9282.Jimmy Zelinskie-2/+2
2013-09-17auto merge of #9133 : dcrewi/rust/bigint-random-range, r=huonwbors-2/+140
2013-09-17Generate random big integers within a rangeDavid Creswick-2/+140
Thanks to @huonw for feedback
2013-09-12std: Rename {Option,Result}::chain{,_err}* to {and_then,or_else}Erick Tryzelaar-4/+4
2013-09-12std: Add Option.{and,and_then,or,or_else}Erick Tryzelaar-2/+2
2013-09-11auto merge of #9014 : dcrewi/rust/convert-between-bigints, r=anasazibors-42/+130
2013-09-11auto merge of #9007 : dcrewi/rust/random-bigints, r=huonwbors-0/+64
2013-09-09auto merge of #9083 : dcrewi/rust/biguint-bit-ops, r=brsonbors-0/+79
2013-09-09Implement bitwise operations on BigUintDavid Creswick-0/+79
2013-09-09Merge RandBigUint and RandBigInt into single traitDavid Creswick-21/+17
2013-09-09Convert between BigInts, BigUints, ints, and uintsDavid Creswick-53/+100
Previously, conversion to ints, uints, and BigUints clamped the value within the range of that datatype. With this commit, conversion overflows fail the task. To handle overflows gracefully, use the new to_*_opt() methods.
2013-09-09rename `std::iterator` to `std::iter`Daniel Micay-2/+2
The trait will keep the `Iterator` naming, but a more concise module name makes using the free functions less verbose. The module will define iterables in addition to iterators, as it deals with iteration in general.