about summary refs log tree commit diff
path: root/src/libstd/num
AgeCommit message (Collapse)AuthorLines
2014-02-01auto merge of #11930 : bjz/rust/next_power_of_two, r=huonwbors-141/+89
2014-01-31Fix minor doc typosVirgile Andreani-10/+10
2014-02-01Move int and uint overflow tests into macrosBrendan Zabarauskas-15/+14
2014-02-01Remove free-standing div functions in std::uintBrendan Zabarauskas-60/+0
2014-02-01Make next_power_of_two generic for unsigned integersBrendan Zabarauskas-66/+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-5/+0
Moving forward to green waterfall.
2014-01-29auto merge of #11672 : bjz/rust/remove-times, r=brsonbors-43/+0
`Times::times` was always a second-class loop because it did not support the `break` and `continue` operations. Its playful appeal (which I liked) was then lost after `do` was disabled for closures. It's time to let this one go.
2014-01-30Remove Times traitBrendan Zabarauskas-43/+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-5/+0
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-01-28Rename CopyableVector to CloneableVectorVirgile Andreani-1/+1
2014-01-25Uppercase numeric constantsChris Wong-272/+272
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
2014-01-22Remove the initial and trailing blank doc-comment linesSiegeLord-80/+0
2014-01-22Add LowerExp 'e' and UpperExp 'E' format traits/specifiersSiegeLord-0/+68
2014-01-22float_to_str_bytes_common can now handle exponential notationSiegeLord-17/+77
2014-01-21[std::str] Rename from_utf8_owned_opt() to from_utf8_owned(), drop the old ↵Simon Sapin-1/+1
from_utf8_owned() behavior
2014-01-21[std::vec] Rename .pop_opt() to .pop(), drop the old .pop() behaviorSimon Sapin-1/+1
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-43/+7
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-84/+31
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-18Add FIXME comments regarding issue #11526.Brendan Zabarauskas-0/+22
2014-01-18Simplify std::num::Primitive trait definitionBrendan Zabarauskas-84/+9
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-40/+68
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-15auto merge of #11548 : bjz/rust/bitwise, r=alexcrichtonbors-37/+38
One less trait in `std::num` and three less exported in the prelude. cc. #10387
2014-01-16Merge Bitwise and BitCount traits and remove from prelude, along with BoundedBrendan Zabarauskas-37/+38
One less trait in std::num, and three less exported in the prelude.
2014-01-15Use the least significant beat to determine if int/uint is evenFlavio Percoco-2/+2
2014-01-13Clean up std::num::cmath and remove stale commentsBrendan Zabarauskas-186/+79
2014-01-13Remove RealExtBrendan Zabarauskas-49/+1
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-272/+232
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-106/+23
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-272/+232
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-07Fix remaining cases of leaking importsAlex Crichton-0/+2
2014-01-07std: Fill in all missing importsAlex Crichton-1/+1
Fallout from the previous commits
2014-01-06Remove some unnecessary type castsFlorian Hahn-1/+1
Conflicts: src/librustc/middle/lint.rs
2014-01-03libstd: Remove all support code related to `@mut`Patrick Walton-5/+0
2013-12-27std: uniform modules titles for docLuca Bruno-13/+15
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-13/+18
2013-12-15std: fix spelling in docs.Huon Wilson-2/+2
2013-12-14Dead-code pass now marks and warns foreign itemsKiet Tran-0/+1
2013-12-08Remove dead codesKiet Tran-17/+17
2013-12-05Fix documentation typo (divison operator is not backslash)Alexandros Tasos-2/+2
2013-12-04auto merge of #10803 : vmx/rust/integer-decode, r=cmrbors-0/+60
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 I got the permission to use this code for Rust from Peter Graves (the ABCL copyright holder) . If there's any further IP clearance needed, let me know.
2013-12-04Decode a float into integersVolker Mische-0/+60
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-12-04std::str: remove from_utf8.Huon Wilson-1/+1
This function had type &[u8] -> ~str, i.e. it allocates a string internally, even though the non-allocating version that take &[u8] -> &str and ~[u8] -> ~str are all that is necessary in most circumstances.
2013-11-29Removed module macro workaround for signed and unsigned integersMarvin Löbel-57/+93
2013-11-29Removed useless cmp::{min, max} reexports from the integer modulesMarvin Löbel-4/+0
2013-11-29Removed a few macro-expanding-to-module workaroundsMarvin Löbel-42/+32
Also documented a few issues
2013-11-26libstd: Fix Win32 and other bustage.Patrick Walton-3/+3
2013-11-26test: Remove non-procedure uses of `do` from compiletest, libstd tests,Patrick Walton-5/+5
compile-fail tests, run-fail tests, and run-pass tests.