about summary refs log tree commit diff
path: root/src/libstd/num
AgeCommit message (Collapse)AuthorLines
2015-05-01std: Don't use a wrapper for the float error typeAlex Crichton-34/+5
Ensures that the same error type is propagated throughout. Unnecessary leakage of the internals is prevented through the usage of stability attributes. Closes #24748
2015-04-21std: Bring back f32::from_str_radix as an unstable APIAlex Crichton-761/+284
This API was exercised in a few tests and mirrors the `from_str_radix` functionality of the integer types.
2015-04-21std: Remove deprecated/unstable num functionalityAlex Crichton-2480/+10
This commit removes all the old casting/generic traits from `std::num` that are no longer in use by the standard library. This additionally removes the old `strconv` module which has not seen much use in quite a long time. All generic functionality has been supplanted with traits in the `num` crate and the `strconv` module is supplanted with the [rust-strconv crate][rust-strconv]. [rust-strconv]: https://github.com/lifthrasiir/rust-strconv This is a breaking change due to the removal of these deprecated crates, and the alternative crates are listed above. [breaking-change]
2015-04-21Model lexer: Fix remaining issuesPiotr Czarnecki-2/+0
2015-04-14rollup merge of #24377: apasel422/docsAlex Crichton-30/+30
Conflicts: src/libstd/net/ip.rs src/libstd/sys/unix/fs.rs src/libstd/sys/unix/mod.rs src/libstd/sys/windows/mod.rs
2015-04-14test: Fixup many library unit testsAlex Crichton-14/+14
2015-04-13pluralize doc comment verbs and add missing periodsAndrew Paseltiner-30/+30
2015-04-07std: Deny most warnings in doctestsAlex Crichton-24/+2
Allow a few specific ones but otherwise this helps ensure that our examples are squeaky clean! Closes #18199
2015-04-01Fallout in public-facing and semi-public-facing libsNiko Matsakis-3/+3
2015-03-31Stabilize std::numAaron Turon-964/+408
This commit stabilizes the `std::num` module: * The `Int` and `Float` traits are deprecated in favor of (1) the newly-added inherent methods and (2) the generic traits available in rust-lang/num. * The `Zero` and `One` traits are reintroduced in `std::num`, which together with various other traits allow you to recover the most common forms of generic programming. * The `FromStrRadix` trait, and associated free function, is deprecated in favor of inherent implementations. * A wide range of methods and constants for both integers and floating point numbers are now `#[stable]`, having been adjusted for integer guidelines. * `is_positive` and `is_negative` are renamed to `is_sign_positive` and `is_sign_negative`, in order to address #22985 * The `Wrapping` type is moved to `std::num` and stabilized; `WrappingOps` is deprecated in favor of inherent methods on the integer types, and direct implementation of operations on `Wrapping<X>` for each concrete integer type `X`. Closes #22985 Closes #21069 [breaking-change]
2015-03-26Mass rename uint/int to usize/isizeAlex Crichton-68/+68
Now that support has been removed, all lingering use cases are renamed.
2015-03-23Add #![feature] attributes to doctestsBrian Anderson-0/+125
2015-03-20std: Remove old_io/old_path from the preludeAlex Crichton-2/+2
This commit removes the reexports of `old_io` traits as well as `old_path` types and traits from the prelude. This functionality is now all deprecated and needs to be removed to make way for other functionality like `Seek` in the `std::io` module (currently reexported as `NewSeek` in the io prelude). Closes #23377 Closes #23378
2015-03-20Rollup merge of #22631 - aepsil0n:issue-22098, r=aturonManish Goregaokar-9/+9
Fixes #22098.
2015-03-19Allow Float::ldexp to be called as a methodEduard Bopp-9/+9
Fixes #22098.
2015-03-18Register new snapshotsAlex Crichton-23/+0
2015-03-16impl f{32,64}Jorge Aparicio-0/+2469
2015-03-16impl {i,u}{8,16,32,64,size}Jorge Aparicio-0/+3
2015-03-16impl<T> [T]Jorge Aparicio-0/+1
2015-03-16impl strJorge Aparicio-0/+1
2015-03-16impl charJorge Aparicio-0/+3
2015-03-08Auto merge of #22984 - carols10cents:tests-for-float, r=huonwbors-345/+925
Building on #22076, I've added some tests for stable methods in f32 and f64 that didn't have any before. Please let me know if there are any improvements I can make, and I am happy to make them! :mailbox_with_mail:
2015-03-07Use assert_eq! rather than assert!Ryan Prichard-1/+1
The previous code was passing "true" as the panic! error value.
2015-03-05Removing unnecessary pub from a test functionCarol Nichols-2/+2
2015-03-05Add tests to stable f32 and f64 methods that didn't have anyCarol Nichols-0/+580
2015-03-05Rearrange tests to be in the same order as implementationCarol Nichols-345/+345
I was having trouble figuring out which functions had tests and which didn't. This commit is just moving tests around and does not change anything.
2015-03-05Remove integer suffixes where the types in compiled code are identical.Eduard Burtescu-31/+31
2015-03-03Auto merge of #22532 - pnkfelix:arith-overflow, r=pnkfelix,eddybbors-12/+14
Rebase and follow-through on work done by @cmr and @aatch. Implements most of rust-lang/rfcs#560. Errors encountered from the checks during building were fixed. The checks for division, remainder and bit-shifting have not been implemented yet. See also PR #20795 cc @Aatch ; cc @nikomatsakis
2015-03-03Rollup merge of #22876 - Florob:const, r=nikomatsakisManish Goregaokar-2/+2
This changes the type of some public constants/statics in libunicode. Notably some `&'static &'static [(char, char)]` have changed to `&'static [(char, char)]`. The regexp crate seems to be the sole user of these, yet this is technically a [breaking-change]
2015-03-03Accommodate arith-overflow in `core::num`, `std::num`, `coretest::num`.Felix S. Klock II-12/+13
* `core::num`: adjust `UnsignedInt::is_power_of_two`, `UnsignedInt::next_power_of_two`, `Int::pow`. In particular for `Int::pow`: (1.) do not panic when `base` overflows if `acc` never observes the overflowed `base`, and (2.) if `acc` does observe the overflowed `base`, make sure we only panic if we would have otherwise (e.g. during a computation of `base * base`). * also in `core::num`: avoid underflow during computation of `uint::MAX`. * `std::num`: adjust tests `uint::test_uint_from_str_overflow`, `uint::test_uint_to_str_overflow`, `strconv` * `coretest::num`: adjust `test::test_int_from_str_overflow`.
2015-03-03Add `core::num::wrapping` and fix overflow errors.James Miller-0/+1
Many of the core rust libraries have places that rely on integer wrapping behaviour. These places have been altered to use the wrapping_* methods: * core::hash::sip - A number of macros * core::str - The `maximal_suffix` method in `TwoWaySearcher` * rustc::util::nodemap - Implementation of FnvHash * rustc_back::sha2 - A number of macros and other places * rand::isaac - Isaac64Rng, changed to use the Wrapping helper type Some places had "benign" underflow. This is when underflow or overflow occurs, but the unspecified value is not used due to other conditions. * collections::bit::Bitv - underflow when `self.nbits` is zero. * collections::hash::{map,table} - Underflow when searching an empty table. Did cause undefined behaviour in this case due to an out-of-bounds ptr::offset based on the underflowed index. However the resulting pointers would never be read from. * syntax::ext::deriving::encodable - Underflow when calculating the index of the last field in a variant with no fields. These cases were altered to avoid the underflow, often by moving the underflowing operation to a place where underflow could not happen. There was one case that relied on the fact that unsigned arithmetic and two's complement arithmetic are identical with wrapping semantics. This was changed to use the wrapping_* methods. Finally, the calculation of variant discriminants could overflow if the preceeding discriminant was `U64_MAX`. The logic in `rustc::middle::ty` for this was altered to avoid the overflow completely, while the remaining places were changed to use wrapping methods. This is because `rustc::middle::ty::enum_variants` now throws an error when the calculated discriminant value overflows a `u64`. This behaviour can be triggered by the following code: ``` enum Foo { A = U64_MAX, B } ``` This commit also implements the remaining integer operators for Wrapped<T>.
2015-03-02core: Audit num module for int/uintBrian Anderson-2/+2
* count_ones/zeros, trailing_ones/zeros return u32, not usize * rotate_left/right take u32, not usize * RADIX, MANTISSA_DIGITS, DIGITS, BITS, BYTES are u32, not usize Doesn't touch pow because there's another PR for it. [breaking-change]
2015-03-02Use `const`s instead of `static`s where appropriateFlorian Zeitz-2/+2
This changes the type of some public constants/statics in libunicode. Notably some `&'static &'static [(char, char)]` have changed to `&'static [(char, char)]`. The regexp crate seems to be the sole user of these, yet this is technically a [breaking-change]
2015-03-01Make Int::pow() take exp as u32 instead usizeGuillaume Gomez-1/+1
2015-02-23Rollup merge of #22658 - glacjay:issue-22535, r=GankroManish Goregaokar-62/+66
fix issue #22535
2015-02-22shift int/uint tests around to avoid code repetitionGlacJAY-62/+66
2015-02-20make int/uint modules just re-exportsAlexis-149/+105
2015-02-18Convert required suffixes into a use of `as`.Niko Matsakis-39/+39
2015-02-18Remove `i`, `is`, `u`, or `us` suffixes that are not necessary.Niko Matsakis-16/+16
2015-02-16Document std::num::Float with examplesmdinger-42/+777
2015-02-15Rollup merge of #22339 - petrochenkov:int, r=huonwManish Goregaokar-21/+21
Some function signatures have changed, so this is a [breaking-change]. In particular, radixes and numerical values of digits are represented by `u32` now. Part of #22240
2015-02-15Fix the falloutVadim Petrochenkov-21/+21
2015-02-13Remove `_VALUE` from the float extremes constants.Huon Wilson-0/+2
In `std::f32` and `std::f64`: - `MIN_VALUE` → `MIN` - `MAX_VALUE` → `MAX` - `MIN_POS_VALUE` → `MIN_POSITIVE` This matches the corresponding integer constants. [breaking-change]
2015-02-11Auto merge of #22076 - carols10cents:exp2-calling-exp, r=huonwbors-2/+56
I was working on adding examples to the documentation in `std::num::Float`. I got to `exp2`, which says "Returns 2 raised to the power of the number, `2^(self)`." So I tried running this code: ``` use std::num::Float; #[test] fn test_exp2() { assert_eq!(32.0, 5.0.exp2()); } ``` and it resulted in a failure of `(left: `32`, right: `148.413159`)`. That 148.413159 is the value for e^5, which is `exp()`, not `exp2()`. Sure enough, `exp2` is calling `exp` and shouldn't be, looks like a copy-paste error. I haven't added any tests for this since it's unlikely to break again, but I will happily do so if people think that would be a good idea. The doc examples are coming :) I scanned through the other functions in these files for similar sorts of errors and didn't notice any.
2015-02-10Auto merge of #21937 - alexcrichton:issue-21929, r=aturonbors-1/+1
These were forgotten reexports from #21718 Closes #21929
2015-02-08Correct fns exp2 that were calling expCarol Nichols-2/+56
Fixes #22080.
2015-02-04remove all kind annotations from closuresJorge Aparicio-2/+2
2015-02-04std: Add reexports for core parse errorsAlex Crichton-1/+1
These were forgotten reexports from #21718 Closes #21929
2015-02-04Deprecate in-tree `rand`, `std::rand` and `#[derive(Rand)]`.Huon Wilson-0/+1
Use the crates.io crate `rand` (version 0.1 should be a drop in replacement for `std::rand`) and `rand_macros` (`#[derive_Rand]` should be a drop-in replacement). [breaking-change]
2015-01-30rollup merge of #21631: tbu-/isize_policeAlex Crichton-23/+23
Conflicts: src/libcoretest/iter.rs