about summary refs log tree commit diff
path: root/src/libcore/num
AgeCommit message (Collapse)AuthorLines
2014-09-17doc: Cleanup.Jonas Hietala-4/+4
Remove ~~~ for code block specification. Use /// Over /** */ for doc blocks.
2014-09-05Make integer bit count methods return uintsBrendan Zabarauskas-10/+10
Fixes rust-lang/rfcs#224
2014-08-26Added a note for usage of abs with ::MIN.Robert Gawdzik ☢-2/+6
2014-08-19auto merge of #16364 : tbu-/rust/pr_checkeddiv0, r=alexcrichtonbors-3/+5
2014-08-08Add division by zero case to the `CheckedDiv` commentTobias Bucher-3/+5
2014-08-08libcore: Fix documentation comment for f32.Ruud van Asseldonk-1/+1
2014-08-04num: Fix the documentation of abs_sub.OGINO Masanori-2/+2
Use proper argument names and unbackquote the word "zero" because it is not an identifier. Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-08-01doc: fix typos in std::num::IntTshepang Lekhonkhobe-2/+2
2014-07-29Improve documentation of rounding functionsPiotr Jawniak-35/+34
2014-07-24Add examples for Checked[Add|Sub|Mul|Div]nham-0/+32
2014-07-24auto merge of #15407 : sneves/rust/master, r=aturonbors-8/+8
At the moment, writing generic functions for integer types that involve shifting is rather verbose. For example, a function at shifts an integer left by 1 currently requires use std::num::One; fn f<T: Int>(x : T) -> T { x << One::one() } If the shift amount is not 1, it's even worse: use std::num::FromPrimitive; fn f<T: Int + FromPrimitive>(x: T) -> T { x << FromPrimitive::from_int(2).unwrap() } This patch allows the much simpler implementation fn f<T: Int>(x: T) -> T { x << 2 } It accomplishes this by changing the built-in integer types (and the `Int` trait) to implement `Shl<uint, T>` instead of `Shl<T, T>` as it currently is defined. Note that the internal implementations of `shl` already cast the right-hand side to `uint`. `BigInt` also implements `Shl<uint, BigInt>`, so this increases consistency. All of the above applies similarly to right shifts, i.e., `Shr<uint, T>`.
2014-07-22Clean up some trait impls in core::num.Tobias Bucher-18/+7
This removes the special casing for `float`s where it was not necessary, as `-0.0 == 0.0`.
2014-07-21Add a ton of ignore-lexer-testCorey Richardson-0/+2
2014-07-10Add range lint for float literals, fixing #10934Falco Hirschenberger-0/+4
2014-07-08make macros non-capturingJohn Clements-67/+67
2014-07-04Change Shl<T, T> for Int to Shl<uint, T>Samuel Neves-8/+8
2014-07-02Fix rotate_{left, right} for multiple of bitsize rotation amountsSamuel Neves-2/+2
Add additional rotation tests
2014-06-29Extract tests from libcore to a separate crateSteven Fackler-271/+0
Libcore's test infrastructure is complicated by the fact that many lang items are defined in the crate. The current approach (realcore/realstd imports) is hacky and hard to work with (tests inside of core::cmp haven't been run for months!). Moving tests to a separate crate does mean that they can only test the public API of libcore, but I don't feel that that is too much of an issue. The only tests that I had to get rid of were some checking the various numeric formatters, but those are also exercised through normal format! calls in other tests.
2014-06-24std: Add stability attributes to primitive numeric modulesBrian Anderson-0/+18
The following are unstable: - core::int, i8, i16, i32, i64 - core::uint, u8, u16, u32, u64 - core::int::{BITS, BYTES, MIN, MAX}, etc. - std::int, i8, i16, i32, i64 - std::uint, u8, u16, u32, u64 The following are experimental: - std::from_str::FromStr and impls - may need to return Result instead of Option - std::int::parse_bytes, etc. - ditto - std::num::FromStrRadix and impls - ditto - std::num::from_str_radix - ditto The following are deprecated: - std::num::ToStrRadix and imples - Wrapper around fmt::radix. Wrong name (Str vs String) See https://github.com/rust-lang/rust/wiki/Meeting-API-review-2014-06-23#uint
2014-06-24librustc: Remove the fallback to `int` from typechecking.Niko Matsakis-7/+7
This breaks a fair amount of code. The typical patterns are: * `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`; * `println!("{}", 3)`: change to `println!("{}", 3i)`; * `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`. RFC #30. Closes #6023. [breaking-change]
2014-06-18Update doc comment for Int traitBrendan Zabarauskas-1/+2
2014-06-18Shorten endian conversion method namesBrendan Zabarauskas-44/+44
The consensus on #14917 was that the proposed names were too long.
2014-06-18Merge the Bitwise and ByteOrder traits into the Int traitBrendan Zabarauskas-133/+310
This reduces the complexity of the trait hierarchy.
2014-06-18Add a ByteOrder trait for abstracting over endian conversionsBrendan Zabarauskas-70/+24
The `Bitwise::swap_bytes` method was also moved into the `ByteOrder` trait. This was because it works on the byte level rather than the bit level.
2014-06-13Add Bitwise::{swap_bytes, rotate_left, rotate_right} methodsBrendan Zabarauskas-20/+152
2014-06-02docs: Stop using `notrust`Florian Gilcher-2/+2
Now that rustdoc understands proper language tags as the code not being Rust, we can tag everything properly. This change tags examples in other languages by their language. Plain notations are marked as `text`. Console examples are marked as `console`. Also fix markdown.rs to not highlight non-rust code.
2014-05-31rustdoc: Create anchor pages for primitive typesAlex Crichton-0/+24
This commit adds support in rustdoc to recognize the `#[doc(primitive = "foo")]` attribute. This attribute indicates that the current module is the "owner" of the primitive type `foo`. For rustdoc, this means that the doc-comment for the module is the doc-comment for the primitive type, plus a signal to all downstream crates that hyperlinks for primitive types will be directed at the crate containing the `#[doc]` directive. Additionally, rustdoc will favor crates closest to the one being documented which "implements the primitive type". For example, documentation of libcore links to libcore for primitive types, but documentation for libstd and beyond all links to libstd for primitive types. This change involves no compiler modifications, it is purely a rustdoc change. The landing pages for the primitive types primarily serve to show a list of implemented traits for the primitive type itself. The primitive types documented includes both strings and slices in a semi-ad-hoc way, but in a way that should provide at least somewhat meaningful documentation. Closes #14474
2014-05-30std: Rename {Eq,Ord} to Partial{Eq,Ord}Alex Crichton-5/+5
This is part of the ongoing renaming of the equality traits. See #12517 for more details. All code using Eq/Ord will temporarily need to move to Partial{Eq,Ord} or the Total{Eq,Ord} traits. The Total traits will soon be renamed to {Eq,Ord}. cc #12517 [breaking-change]
2014-05-28Move trait impls for primitives near trait definitionPiotr Jawniak-1222/+363
Closes #12925
2014-05-19Minor doc fixes in various placesPiotr Jawniak-17/+21
2014-05-15core: Move intrinsic float functionality from stdAlex Crichton-2/+699
The Float trait in libstd is quite a large trait which has dependencies on cmath (libm) and such, which libcore cannot satisfy. It also has many functions that libcore can implement, however, as LLVM has intrinsics or they're just bit twiddling. This commit moves what it can of the Float trait from the standard library into libcore to allow floats to be usable in the core library. The remaining functions are now resident in a FloatMath trait in the standard library (in the prelude now). Previous code which was generic over just the Float trait may now need to be generic over the FloatMath trait. [breaking-change]
2014-05-07core: Fix an unsigned negation warningAlex Crichton-1/+1
2014-05-07core: Get coretest workingAlex Crichton-31/+95
This mostly involved frobbing imports between realstd, realcore, and the core being test. Some of the imports are a little counterintuitive, but it mainly focuses around libcore's types not implementing Show while libstd's types implement Show.
2014-05-07core: Add a limited implementation of failureAlex Crichton-42/+42
This adds an small of failure to libcore, hamstrung by the fact that std::fmt hasn't been migrated yet. A few asserts were re-worked to not use std::fmt features, but these asserts can go back to their original form once std::fmt has migrated. The current failure implementation is to just have some symbols exposed by std::rt::unwind that are linked against by libcore. This is an explicit circular dependency, unfortunately. This will be officially supported in the future through compiler support with much nicer failure messages. Additionally, there are two depended-upon symbols today, but in the future there will only be one (once std::fmt has migrated).
2014-05-07core: Inherit the specific numeric modulesAlex Crichton-0/+1729
This implements all traits inside of core::num for all the primitive types, removing all the functionality from libstd. The std modules reexport all of the necessary items from the core modules.
2014-05-07core: Inherit what's possible from the num moduleAlex Crichton-0/+860
This strips out all string-related functionality from the num module. The inherited functionality is all that will be implemented in libcore (for now). Primarily, libcore will not implement the Float trait or any string-related functionality. It may be possible to migrate string parsing functionality into libcore in the future, but for now it will remain in libstd. All functionality in core::num is reexported in std::num.
2013-05-22libstd: Rename libcore to libstd and libstd to libextra; update makefiles.Patrick Walton-7635/+0
This only changes the directory names; it does not change the "real" metadata names.
2013-05-19Register snapshotsBrian Anderson-100/+0
2013-05-19Use assert_eq! rather than assert! where possibleCorey Richardson-54/+54
2013-05-18auto merge of #6586 : bjz/rust/formatting-and-conditionals, r=thestingerbors-4/+52
2013-05-18Use cond! macro where appropriateBrendan Zabarauskas-4/+52
2013-05-18Some cosmetic changes to num.rsMarvin Löbel-5/+4
2013-05-17Implement sin_cos method for float, f64 and f32Brendan Zabarauskas-0/+21
2013-05-14Fix cosmetics for fail!() callsMarvin Löbel-9/+7
2013-05-14Use static string with fail!() and remove fail!(fmt!())Björn Steinbrink-27/+27
fail!() used to require owned strings but can handle static strings now. Also, it can pass its arguments to fmt!() on its own, no need for the caller to call fmt!() itself.
2013-05-14auto merge of #6463 : bjz/rust/numeric-traits, r=thestingerbors-1/+445
This is part of the numeric trait reform tracked on issue #4819
2013-05-14Remove unnecessary infinity checkBrendan Zabarauskas-4/+2
2013-05-14Add ldexp and frexp functionsBrendan Zabarauskas-1/+184
2013-05-13Remove re-exports from libcore/core.rcAlex Crichton-0/+3
Also fix up all the fallout elsewhere throughout core. It's really nice being able to have the prelude.
2013-05-14Add inverse hyperbolic functionsBrendan Zabarauskas-0/+263