about summary refs log tree commit diff
path: root/src/libcore/num
AgeCommit message (Collapse)AuthorLines
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
2013-05-12libsyntax: Tighten up expressions in patterns to only allow identifiers or ↵Patrick Walton-5/+5
literals (possibly with a minus). This had very minimal fallout.
2013-05-13Make Float::classify matching more clear for f64 and f32Brendan Zabarauskas-20/+14
2013-05-10core: Use the new `for` protocolAlex Crichton-13/+88
2013-05-08Remove #[cfg(notest)] and use #[cfg(not(test))] to cooincide with #[cfg(debug)]Zack Corr-55/+55
2013-05-07Add is_normal and classify methods to Float traitBrendan Zabarauskas-17/+170
2013-05-07Add abs_sub method to Signed traitBrendan Zabarauskas-5/+126
2013-05-07Fix order of methodsBrendan Zabarauskas-24/+26
2013-05-07Implement exp_m1 and ln_1p as methods for FloatBrendan Zabarauskas-22/+65
Both expm1 and ln1p have been renamed to exp_m1 and ln_1p in order to be consistent with the underscore usage elsewhere. The exp_m1 method is used for increased accuracy when doing floating point calculations, so this has been moved from the more general 'Exponential' trait into 'Float'.
2013-05-07Switch to using 'ln' for the natural logarithm and 'log' for arbitrary base ↵Brendan Zabarauskas-36/+49
logarithms
2013-05-06Add assert_approx_eq! macroBrendan Zabarauskas-223/+195
2013-05-06Move FuzzyEq trait into core::cmp and rename it to 'ApproxEq'Brendan Zabarauskas-2/+78
2013-05-04Register snapshotsBrian Anderson-58/+6
2013-05-02libcore: Export core::from_str::FromStr from core::preludegifnksm-8/+3
2013-05-02Remove 'Local Variable' commentsBrendan Zabarauskas-41/+0
2013-05-01Revert rename of Div to QuotBrendan Zabarauskas-126/+99
2013-04-29auto merge of #6110 : bjz/rust/numeric-traits, r=pcwaltonbors-252/+354
As discussed on issue #4819, I have created four new traits: `Algebraic`, `Trigonometric`, `Exponential` and `Hyperbolic`, and moved the appropriate methods into them from `Real`. ~~~rust pub trait Algebraic { fn pow(&self, n: Self) -> Self; fn sqrt(&self) -> Self; fn rsqrt(&self) -> Self; fn cbrt(&self) -> Self; fn hypot(&self, other: Self) -> Self; } pub trait Trigonometric { fn sin(&self) -> Self; fn cos(&self) -> Self; fn tan(&self) -> Self; fn asin(&self) -> Self; fn acos(&self) -> Self; fn atan(&self) -> Self; fn atan2(&self, other: Self) -> Self; } pub trait Exponential { fn exp(&self) -> Self; fn exp2(&self) -> Self; fn expm1(&self) -> Self; fn log(&self) -> Self; fn log2(&self) -> Self; fn log10(&self) -> Self; } pub trait Hyperbolic: Exponential { fn sinh(&self) -> Self; fn cosh(&self) -> Self; fn tanh(&self) -> Self; } ~~~ There was some discussion over whether we should shorten the names, for example `Trig` and `Exp`. No abbreviations have been agreed on yet, but this could be considered in the future. Additionally, `Integer::divisible_by` has been renamed to `Integer::is_multiple_of`.