about summary refs log tree commit diff
path: root/src/libstd/num/mod.rs
AgeCommit message (Collapse)AuthorLines
2014-02-22Move std::num::Integer to libnumBrendan Zabarauskas-27/+7
2014-02-20move extra::test to libtestLiigo Zhuang-1/+2
2014-02-17auto merge of #12321 : bjz/rust/remove-real, r=alexcrichtonbors-172/+166
This is part of the effort to simplify `std::num`, as tracked in issue #10387. It is also a step towards a proper IEEE-754 trait (see #12281).
2014-02-17Rename Bitwise::population_count to Bitwise::count_ones and add ↵Brendan Zabarauskas-6/+25
Bitwise::count_zeros These are inspired by the [functions in the Julia standard library](http://docs.julialang.org/en/release-0.2/stdlib/base/#Base.count_ones).
2014-02-17Remove Real trait and move methods into FloatBrendan Zabarauskas-172/+166
This is part of the effort to simplify `std::num`, as tracked in issue #10387.
2014-02-14Fix all code examplesAlex Crichton-2/+4
2014-02-14Enable 64-bit checked multiplication on 32-bitAlex Crichton-1/+1
This was just waiting for compiler-rt support, which was added in #12027 Closes #8449
2014-02-13Removed num::OrderableMichael Darakananda-20/+3
2014-02-01Make next_power_of_two generic for unsigned integersBrendan Zabarauskas-1/+75
Also rename `next_power_of_two_opt` to `checked_next_power_of_two`.
2014-01-31auto merge of #11918 : omasanori/rust/reduce-warnings, r=alexcrichtonbors-1/+0
Moving forward to green waterfall.
2014-01-30Remove Times traitBrendan Zabarauskas-12/+0
`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-30Remove unused imports.OGINO Masanori-1/+0
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-01-25Uppercase numeric constantsChris Wong-245/+245
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
2014-01-20Improve std::num::pow implementationBrendan Zabarauskas-42/+30
The implementation has been made more succinct and no longer requires Clone. The coverage of the associated unit test has also been increased to check more combinations of bases, exponents, and expected results.
2014-01-20Add operator trait constraints to std::num::{Zero, One} and document their ↵Brendan Zabarauskas-16/+46
appropriate use Zero and One have precise definitions in mathematics. Documentation has been added to describe the appropriate uses for these traits and the laws that they should satisfy. For more information regarding these identities, see the following wikipedia pages: - http://wikipedia.org/wiki/Additive_identity - http://wikipedia.org/wiki/Multiplicative_identity
2014-01-18Replace old pow_with_uint with the new pow funcFlavio Percoco-37/+0
There was an old and barely used implementation of pow, which expected both parameters to be uint and required more traits to be implemented. Since a new implementation for `pow` landed, I'm proposing to remove this old impl in favor of the new one. The benchmark shows that the new implementation is faster than the one being removed: test num::bench::bench_pow_function ..bench: 9429 ns/iter (+/- 2055) test num::bench::bench_pow_with_uint_function ...bench: 28476 ns/iter (+/- 2202)
2014-01-18Added benchmark for pow and pow_with_uintFlavio Percoco-0/+21
2014-01-18auto merge of #11622 : bjz/rust/simplify-primitive-trait, r=brsonbors-16/+5
As part of #10387, this removes the `Primitive::{bits, bytes, is_signed}` methods and removes the trait's operator trait constraints for the reasons outlined below: - The `Primitive::{bits, bytes}` associated functions were originally added to reflect the existing `BITS` and `BYTES`statics included in the numeric modules. These statics are only exist as a workaround for Rust's lack of CTFE, and should be deprecated in the future in favor of using the `std::mem::size_of` function (see #11621). - `Primitive::is_signed` seems to be of little utility and does not seem to be used anywhere in the Rust compiler or libraries. It is also rather ugly to call due to the `Option<Self>` workaround for #8888. - The operator trait constraints are already covered by the `Num` trait.
2014-01-18Simplify std::num::Primitive trait definitionBrendan Zabarauskas-16/+5
This removes the `Primitive::{bits, bytes, is_signed}` methods and removes the operator trait constraints, for the reasons outlined below: - The `Primitive::{bits, bytes}` associated functions were originally added to reflect the existing `BITS` and `BYTES` statics included in the numeric modules. These statics are only exist as a workaround for Rust's lack of CTFE, and should probably be deprecated in the future in favor of using the `std::mem::size_of` function (see #11621). - `Primitive::is_signed` seems to be of little utility and does not seem to be used anywhere in the Rust compiler or libraries. It is also rather ugly to call due to the `Option<Self>` workaround for #8888. - The operator trait constraints are already covered by the `Num` trait.
2014-01-17Add a generic power functionFlavio Percoco-4/+64
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-14/+17
One less trait in std::num, and three less exported in the prelude.
2014-01-13Remove RealExtBrendan Zabarauskas-18/+0
These functions are of little utility outside a small subset of use cases. If people need them for their own projects then they can use their own bindings for libm (which aren't hard to make).
2014-01-09auto merge of #11412 : bjz/rust/num-cleanups, r=alexcrichtonbors-113/+93
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-56/+3
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-113/+93
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-03libstd: Remove all support code related to `@mut`Patrick Walton-5/+0
2013-12-27std: uniform modules titles for docLuca Bruno-1/+1
This commit uniforms the short title of modules provided by libstd, in order to make their roles more explicit when glancing at the index. Signed-off-by: Luca Bruno <lucab@debian.org>
2013-12-23std: Fix all code examplesAlex Crichton-11/+14
2013-12-15std: fix spelling in docs.Huon Wilson-2/+2
2013-12-04Decode a float into integersVolker Mische-0/+2
The `integer_decode()` function decodes a float (f32/f64) into integers containing the mantissa, exponent and sign. It's needed for `rationalize()` implementation of #9838. The code got ported from ABCL [1]. [1] http://abcl.org/trac/browser/trunk/abcl/src/org/armedbear/lisp/FloatFunctions.java?rev=14465#L94
2013-11-26libstd: Fix Win32 and other bustage.Patrick Walton-1/+1
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-1/+1
2013-11-11Use constants instead of raw values.Jay Anderson-4/+2
2013-11-11Got directions backwards in to_degrees and to_radians docs.Jay Anderson-2/+2
2013-11-11Add docs for traits Exponential, Hyperbolic, BitCount.Jay Anderson-2/+44
2013-11-11Update docs for Fractional, Algebraic, Round, and Trigonometric traits.Jay Anderson-0/+89
2013-11-03Rename files to match current recommendations.Chris Morgan-0/+1596
New standards have arisen in recent months, mostly for the use of rustpkg, but the main Rust codebase has not been altered to match these new specifications. This changeset rectifies most of these issues. - Renamed the crate source files `src/libX/X.rs` to `lib.rs`, for consistency with current styles; this affects extra, rustc, rustdoc, rustpkg, rustuv, std, syntax. - Renamed `X/X.rs` to `X/mod.rs,` as is now recommended style, for `std::num` and `std::terminfo`. - Shifted `src/libstd/str/ascii.rs` out of the otherwise unused `str` directory, to be consistent with its import path of `std::ascii`; libstd is flat at present so it's more appropriate thus. While this removes some `#[path = "..."]` directives, it does not remove all of them, and leaves certain other inconsistencies, such as `std::u8` et al. which are actually stored in `src/libstd/num/` (one subdirectory down). No quorum has been reached on this issue, so I felt it best to leave them all alone at present. #9208 deals with the possibility of making libstd more hierarchical (such as changing the crate to match the current filesystem structure, which would make the module path `std::num::u8`). There is one thing remaining in which this repository is not rustpkg-compliant: rustpkg would have `src/std/` et al. rather than `src/libstd/` et al. I have not endeavoured to change that at this point as it would guarantee prompt bitrot and confusion. A change of that magnitude needs to be discussed first.