about summary refs log tree commit diff
path: root/src/libstd/num/num.rs
AgeCommit message (Collapse)AuthorLines
2013-11-03Rename files to match current recommendations.Chris Morgan-1596/+0
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.
2013-10-28Capitalize statics in f32 and f64 modsZiad Hatahet-3/+3
Fixes #10077
2013-10-16Fixed example comment for num::cast().Ziad Hatahet-1/+1
2013-10-16Added comments to public functions in num.rs.Vijay Korapaty-2/+70
Copied existing comments from other files, and added comments to functions that did not have existing comments available.
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-07std: fix an infinite loop in num::ToPrimitive and add testsErick Tryzelaar-3/+48
2013-10-05std: add Primitive.is_signedErick Tryzelaar-0/+1
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-83/+341
2013-10-01remove the `float` typeDaniel Micay-7/+0
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-25rustdoc: Change all code-blocks with a scriptAlex Crichton-4/+4
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-19Rename the NaN and is_NaN methods to lowercase.Chris Morgan-2/+2
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-15Remove {uint,int,u64,i64,...}::from_str,from_str_radixblake2-ppc-0/+5
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-14Add Orderable bound to num::PrimitiveBrendan Zabarauskas-0/+1
2013-09-08Add Clone and DeepClone constraints to Primitive traitBrendan Zabarauskas-1/+4
2013-09-08Moved checked trait impls out of std::numBrendan Zabarauskas-378/+1
This follows the same pattern as the other numeric trait impls, and reduces the clutter in std::num.
2013-08-30std: Add a fixme for when we add Trait::<for T>::static_method()Erick Tryzelaar-0/+2
2013-08-29Remove the iter module.Jason Fager-0/+13
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-27librustc: Ensure that type parameters are in the right positions in paths.Patrick Walton-12/+12
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-19auto merge of #8459 : thestinger/rust/checked, r=graydonbors-0/+4
2013-08-14Rewrite Saturating in terms of CheckedAdd/CheckedSubKevin Ballard-38/+25
2013-08-12Forbid pub/priv where it has no effectAlex Crichton-2/+2
Closes #5495
2013-08-12fix build with the new snapshot compilerDaniel Micay-37/+14
2013-08-11num: implement CheckedDivDaniel Micay-0/+4
2013-08-11disable 64-bit CheckedMul on 32-bitDaniel Micay-2/+4
code generation problem reported as issue #8449
2013-08-11add intrinsics for checked overflow add/sub/mulDaniel Micay-1/+448
2013-08-05Add std::num::SaturatingKevin Ballard-60/+157
Saturating is an implementation of saturating math operations (at the moment just add and sub) for integral types.
2013-07-30Improve std::num module description, and fix some formattingBrendan Zabarauskas-21/+4
2013-07-30Add some missing method wrappers to std::numBrendan Zabarauskas-2/+24
2013-07-18librustc: Forbid `&` pointers (other than `&'static`) inside `@` boxes.Patrick Walton-2/+2
This makes custom borrowing implementations for custom smart pointers sound.
2013-07-17librustc: Remove all uses of the `Copy` bound.Patrick Walton-2/+1
2013-07-08 Replaces the free-standing functions in f32, &c.Jens Nockert-5/+34
The free-standing functions in f32, f64, i8, i16, i32, i64, u8, u16, u32, u64, float, int, and uint are replaced with generic functions in num instead. If you were previously using any of those functions, just replace them with the corresponding function with the same name in num. Note: If you were using a function that corresponds to an operator, use the operator instead.
2013-06-28librustc: Remove the broken overloaded assign-ops from the language.Patrick Walton-1/+1
They evaluated the receiver twice. They should be added back with `AddAssign`, `SubAssign`, etc., traits.
2013-06-18replace #[inline(always)] with #[inline]. r=burningtree.Graydon Hoare-17/+17
2013-06-16Add copies to type params with Copy boundNiko Matsakis-3/+3
2013-06-14Add Zero impls for lots of common typesAlex Crichton-0/+15
2013-06-11std: convert pow, hypot, atan2, log to take arguments by reference.Huon Wilson-4/+4
2013-05-30Require documentation by default for libstdAlex Crichton-0/+3
Adds documentation for various things that I understand. Adds #[allow(missing_doc)] for lots of things that I don't understand.
2013-05-22libstd: Rename libcore to libstd and libstd to libextra; update makefiles.Patrick Walton-0/+494
This only changes the directory names; it does not change the "real" metadata names.