summary refs log tree commit diff
path: root/src/libstd/num
AgeCommit message (Collapse)AuthorLines
2013-10-08Fix float to float ToPrimitive implementation.Sébastien Crozet-2/+1
The mimimum (negative) value of a float is -Bounded::max_value(), not Bounded::min_value().
2013-10-08auto merge of #9757 : erickt/rust/master, r=alexcrichtonbors-3/+48
I accidentally left an infinite loop in a default method in `num::ToPrimitive::to_u64()`. This fixes it.
2013-10-07std: fix an infinite loop in num::ToPrimitive and add testsErick Tryzelaar-3/+48
2013-10-07Fix existing privacy/visibility violationsAlex Crichton-2/+2
This commit fixes all of the fallout of the previous commit which is an attempt to refine privacy. There were a few unfortunate leaks which now must be plugged, and the most horrible one is the current `shouldnt_be_public` module now inside `std::rt`. I think that this either needs a slight reorganization of the runtime, or otherwise it needs to just wait for the external users of these modules to get replaced with their `rt` implementations. Other fixes involve making things pub which should be pub, and otherwise updating error messages that now reference privacy instead of referencing an "unresolved name" (yay!).
2013-10-05std: add Primitive.is_signedErick Tryzelaar-0/+13
2013-10-05std: ToPrimitive's default impls should use `.to_*()`Erick Tryzelaar-22/+11
This allows the default methods to be properly range checked.
2013-10-05std: fix some warningsErick Tryzelaar-5/+0
2013-10-05std: check bounds for ints/uints in {To,From}PrimitiveErick Tryzelaar-60/+598
2013-10-02std: Swap {To,From}Primitive to use the 64bit as the unimplemented versionErick Tryzelaar-32/+36
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-96/+354
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-02auto merge of #9638 : ↵bors-0/+2
pnkfelix/rust/fsk-issue7526-attempt-to-catch-nonuc-statics-in-match-patterns, r=alexcrichton r? anyone Address scariest part of #7526 by adding a new more specific lint (that is set to warn by default, rather than allow).
2013-10-01Migrate users of 'loop' to 'continue'Alex Crichton-1/+1
Closes #9467
2013-10-01remove the `float` typeDaniel Micay-1454/+2
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-30std: Remove usage of fmt!Alex Crichton-16/+16
2013-10-01Add new lint: non_uppercase_pattern_statics, for #7526.Felix S. Klock II-0/+2
This tries to warn about code like: ```rust match (0,0) { (0, aha) => { ... }, ... } ``` where `aha` is actually a static constant, not a binding.
2013-09-25rustdoc: Change all code-blocks with a scriptAlex Crichton-22/+22
find src -name '*.rs' | xargs sed -i '' 's/~~~.*{\.rust}/```rust/g' find src -name '*.rs' | xargs sed -i '' 's/ ~~~$/ ```/g' find src -name '*.rs' | xargs sed -i '' 's/^~~~$/ ```/g'
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-21auto merge of #9369 : sebcrozet/rust/f64_inline, r=thestingerbors-0/+1
This was, somehow, missed by #8332.
2013-09-20Implement a web backend for rustdoc_ngAlex Crichton-0/+2
This large commit implements and `html` output option for rustdoc_ng. The executable has been altered to be invoked as "rustdoc_ng html <crate>" and it will dump everything into the local "doc" directory. JSON can still be generated by changing 'html' to 'json'. This also fixes a number of bugs in rustdoc_ng relating to comment stripping, along with some other various issues that I found along the way. The `make doc` command has been altered to generate the new documentation into the `doc/ng/$(CRATE)` directories.
2013-09-21std: add missing #[inline] annotation to the f64 neg method.Sébastien Crozet-0/+1
This was, somehow, missed by #8332.
2013-09-19Rename the NaN and is_NaN methods to lowercase.Chris Morgan-115/+115
This is for consistency in naming conventions. - ``std::num::Float::NaN()`` is changed to ``nan()``; - ``std::num::Float.is_NaN()`` is changed to ``is_nan()``; and - ``std::num::strconv::NumStrConv::NaN()`` is changed to ``nan()``. Fixes #9319.
2013-09-19auto merge of #9291 : jzelinskie/rust/remove-cond, r=alexcrichtonbors-41/+41
This is my first contribution, so please point out anything that I may have missed. I consulted IRC and settled on `match () { ... }` for most of the replacements.
2013-09-18Remove and replace cond! Closes #9282.Jimmy Zelinskie-41/+41
2013-09-18std: Remove {float,f64,f32}::from_str in favor of from_strblake2-ppc-211/+187
Like issue #9209, remove float::{from_str, from_str_radix} in favor of the two corresponding traits. The same for modules f64 and f32. New usage is from_str::<float>("1.2e34")
2013-09-16std::num: Add uint::next_power_of_two_optblake2-ppc-1/+11
Like next_power_of_two, but returns None on overflow.
2013-09-15Remove {uint,int,u64,i64,...}::from_str,from_str_radixblake2-ppc-90/+65
Remove these in favor of the two traits themselves and the wrapper function std::from_str::from_str. Add the function std::num::from_str_radix in the corresponding role for the FromStrRadix trait.
2013-09-15std::num: Remove `range_step` for each numeric typeblake2-ppc-296/+0
Replaced by `std::iter::range_step`
2013-09-14auto merge of #9182 : bjz/rust/master, r=brsonbors-0/+1
Somehow this was missed! cc #4819
2013-09-14Add Orderable bound to num::PrimitiveBrendan Zabarauskas-0/+1
2013-09-12std: Add a bunch of Default implsErick Tryzelaar-0/+30
2013-09-09auto merge of #9051 : bjz/rust/master, r=huonwbors-384/+419
2013-09-08auto merge of #8988 : cmr/rust/fromstr_fn, r=brsonbors-3/+3
It just calls out to the associated function on the trait.
2013-09-08Fix import order which caused the wrong from_str to be in scopeCorey Richardson-3/+3
2013-09-09Fix unused import warnings on 32bit systemsBrendan Zabarauskas-2/+6
2013-09-08Add Clone and DeepClone constraints to Primitive traitBrendan Zabarauskas-1/+4
2013-09-08Moved checked trait impls out of std::numBrendan Zabarauskas-383/+411
This follows the same pattern as the other numeric trait impls, and reduces the clutter in std::num.
2013-09-06auto merge of #9010 : aaronlaursen/rust/master, r=alexcrichtonbors-4/+31
Here's a fix for issue #7588, "Overflow handling of from_str methods is broken". The integer overflow issues are taken care of by checking to see if the multiply-by-radix-and-add-next-digit process is reversible. If it overflowed, then some information is lost and the process is irreversible, in which case, None is returned. Floats now consistently return Some(Inf) of Some(-Inf) on overflow thanks to a call to NumStrConv::inf() and NumStrConv::neg_inf() respectively when the overflow is detected (which yields a value of None in the case of ints and uints anyway). This is my first contribution to Rust, and my first time using the language in general, so any and all feedback is appreciated.
2013-09-06fix for issue #7588, overflow now handled correctlyAaron Laursen-4/+31
2013-09-05Rename str::from_bytes to str::from_utf8, closes #8985Florian Hahn-3/+3
2013-08-30auto merge of #8896 : lightcatcher/rust/default_eq_fix, r=thestingerbors-10/+0
Summary: -removed "ne" methods in libstd and librustpkg -made default "ne" be inlined -made one of the "eq" methods in librustpkg follow more standard parameter naming convention
2013-08-30remove several 'ne' methodsEric Martin-10/+0
2013-08-30std: Add a fixme for when we add Trait::<for T>::static_method()Erick Tryzelaar-0/+2
2013-08-29auto merge of #8819 : vadimcn/rust/unit-tests, r=brsonbors-0/+21
Some of the tests are failing. I've only managed to fix 'memory_map_file', the rest are up for grabs... Fixes #5261.
2013-08-29Remove the iter module.Jason Fager-3/+16
Moves the Times trait to num while the question of whether it should exist at all gets hashed out as a completely separate question.
2013-08-28Disabled failing parts of abs_sub() and frexp() unit tests on Windows.Vadim Chugunov-0/+21
2013-08-27librustc: Ensure that type parameters are in the right positions in paths.Patrick Walton-216/+415
This removes the stacking of type parameters that occurs when invoking trait methods, and fixes all places in the standard library that were relying on it. It is somewhat awkward in places; I think we'll probably want something like the `Foo::<for T>::new()` syntax.
2013-08-22Enabled unit tests in std and extra.Vadim Chugunov-5/+0
2013-08-21auto merge of #8610 : kballard/rust/mod_floor, r=alexcrichtonbors-2/+15
`mod_floor()` was incorrectly defined for uint types as `a / b` instead of `a % b`.
2013-08-20rm obsolete float to_str_radix free functionsDaniel Micay-74/+53