about summary refs log tree commit diff
path: root/src/libcore/num
AgeCommit message (Collapse)AuthorLines
2013-04-29Revert "Merge Exponential and Hyperbolic traits"Brendan Zabarauskas-3/+9
After discussions on IRC and #4819, we have decided to revert this change. This is due to the traits expressing different ideas and because hyperbolic functions are not trivially implementable from exponential functions for floating-point types.
2013-04-29Merge Exponential and Hyperbolic traitsBrendan Zabarauskas-9/+3
The Hyperbolic Functions are trivially implemented in terms of `exp`, so it's simpler to group them the Exponential trait. In the future these would have default implementations.
2013-04-29Rename 'divisible_by' method to 'is_multiple_of', add tests for 'is_odd' and ↵Brendan Zabarauskas-5/+67
'is_even'
2013-04-29Move appropriate functions out of Real and into separate Algebraic, ↵Brendan Zabarauskas-247/+287
Trigonometric, Exponential and Hyperbolic traits
2013-04-28make way for a new iter moduleDaniel Micay-1/+1
2013-04-27Propagate NaNs for Orderable methods impled on floating-point primitivesBrendan Zabarauskas-15/+75
2013-04-27Fix copy-paste mistakesBrendan Zabarauskas-5/+5
2013-04-27Remove unnecessary fallbacksBrendan Zabarauskas-82/+0
The `target_word_size` attribute is always available at compile time, so there is no need for a fallback.
2013-04-27Rename `nextafter` to `next_after` to match method name in FloatBrendan Zabarauskas-8/+9
2013-04-27Add additional constants to primitive floating point numbersBrendan Zabarauskas-1/+96
These follow the values defined in the C99 standard
2013-04-27Add mul_add and next_after methods to FloatBrendan Zabarauskas-2/+55
2013-04-27Add Orderable traitBrendan Zabarauskas-2/+152
This is a temporary trait until we have default methods. We don't want to encumber all implementors of Ord by requiring them to implement these functions, but at the same time we want to be able to take advantage of the speed of the specific numeric functions (like the `fmin` and `fmax` intrinsics).
2013-04-26Combine PrimitiveInt, Int, and Uint traits into one single traitBrendan Zabarauskas-22/+6
Having three traits for primitive ints/uints seemed rather excessive. If users wish to specify between them they can simply combine Int with either the Signed and Unsigned traits. For example: fn foo<T: Int + Signed>() { … }
2013-04-26Add BitCount traitBrendan Zabarauskas-14/+285
2013-04-26Add Int, Uint and Float traits for primitive numbersBrendan Zabarauskas-48/+120
2013-04-26Add Bitwise, Bounded, Primitive, and PrimitiveInt traitsBrendan Zabarauskas-0/+254
2013-04-26Minor style improvements for test functionsBrendan Zabarauskas-5/+2
Use argument pattern-matching for test_division_rule and remove visibility specifier for test_signed
2013-04-26Use `///` doc-comment form instead of `/** */`Brendan Zabarauskas-663/+662
2013-04-26Add is_zero method to ZeroBrendan Zabarauskas-37/+40
2013-04-25Restore Round trait and move appropriate methods out of RealBrendan Zabarauskas-65/+305
2013-04-25Add Fractional, Real and RealExt traitsBrendan Zabarauskas-71/+722
2013-04-25Use borrowed pointers for Integer methodsBrendan Zabarauskas-71/+71
This brings them in line with the quot and rem traits, and is be better for large Integer types like BigInt and BigUint because they don't need to be copied unnecessarily.
2013-04-25Rename Natural to IntegerBrendan Zabarauskas-3/+3
'Natural' normally means 'positive integer' in mathematics. It is therefore strange to implement it on signed integer types. 'Integer' is probably a better choice.
2013-04-25Use #[cfg(not(stage0))] to exclude items from stage0Brendan Zabarauskas-39/+11
As requested on the mailing list: https://mail.mozilla.org/pipermail/rust-dev/2013-April/003713.html
2013-04-25Move impls of `Num` out of core::num and clean up importsBrendan Zabarauskas-77/+53
2013-04-24Removed ascii functions from other modulesMarvin Löbel-7/+0
Replaced str::to_lowercase and str::to_uppercase
2013-04-24Implement Natural traitBrendan Zabarauskas-0/+333
This adds the following methods to ints and uints: - div - modulo - div_mod - quot_rem - gcd - lcm - divisible_by - is_even - is_odd I have not implemented Natural for BigInt and BigUInt because they're a little over my head.
2013-04-24Implement Signed and Unsigned traits and remove related predicate functionsBrendan Zabarauskas-159/+292
2013-04-23auto merge of #6034 : thestinger/rust/num, r=catamorphism,pcwaltonbors-0/+58
2013-04-23inline the primitive numeric operationsDaniel Micay-0/+58
2013-04-23Attempt to fix x86 only strconv test failureMarvin Löbel-3/+2
2013-04-22core: ignore test from_str_ignore_underscores. Broken on i686. #6018Brian Anderson-0/+1
2013-04-22Rename Div operator trait to Quot and Modulo operator trait to RemBrendan Zabarauskas-107/+192
2013-04-21librustc: use LLVM intrinsics for several floating point operations.Huon Wilson-153/+166
Achieves at least 5x speed up for some functions! Also, reorganise the delegation code so that the delegated function wrappers have the #[inline(always)] annotation, and reduce the repetition of delegate!(..).
2013-04-19librustc: WIP patch for using the return value.Patrick Walton-2/+2
2013-04-19Use assert_eq! instead of assert! and remove extraneous parenthesesBrendan Zabarauskas-267/+260
2013-04-18Add #[inline(always)] to each operator methodBrendan Zabarauskas-0/+50
2013-04-18Implement bitwise operator traits for ints and uintsBrendan Zabarauskas-0/+69
2013-04-16libcore,std,syntax,rustc: move tests into `mod tests`, make them private (no ↵Huon Wilson-506/+522
pub mod or pub fn).
2013-04-14core: remove unnecessary unsafe blocks/functionsAlex Crichton-6/+6
2013-04-14Remove unnecessary enclosing modules for NumCast implsBrendan Zabarauskas-30/+22
2013-04-14Consolidate tests of numeric operationsBrendan Zabarauskas-83/+29
2013-04-14Restore Num traitBrendan Zabarauskas-0/+22
This restores the trait that was lost in 216e85fadf465c25fe7bc4a9f06f8162ec12b552. It will eventually be broken up into a more fine-grained trait hierarchy in the future once a design can be agreed upon.
2013-04-14Remove trailing whitespaceBrendan Zabarauskas-5/+5
2013-04-14Add a test to show how NumCast can be used in type parametersBrendan Zabarauskas-1/+24
2013-04-14Generate NumCast impls and tests using macrosBrendan Zabarauskas-922/+114
2013-04-14Clarify purpose of NumCast traitBrendan Zabarauskas-2/+2
2013-04-09auto merge of #5769 : gifnksm/rust/range_step, r=bstriebors-10/+49
`uint::range_step` or `int::range_step` causes overflow or underflow as following. code: ```rust fn main() { for uint::range_step(3, 0, -2) |n| { println(fmt!("%u", n)); } } ``` output: ``` 3 1 18446744073709551615 18446744073709551613 ... ``` This commit fixes this behavior as follows. ``` 3 1 ```
2013-04-08auto merge of #5787 : alexcrichton/rust/less-mut-fields, r=catamorphismbors-47/+33
This removes some of the easier instances of mutable fields where the explicit self can just become `&mut self` along with removing some unsafe blocks which aren't necessary any more now that purity is gone. Most of #4568 is done, except for [one case](https://github.com/alexcrichton/rust/blob/less-mut-fields/src/libcore/vec.rs#L1754) where it looks like it has to do with it being a `const` vector. Removing the unsafe block yields: ``` /Users/alex/code/rust2/src/libcore/vec.rs:1755:12: 1755:16 error: illegal borrow unless pure: creating immutable alias to const vec content /Users/alex/code/rust2/src/libcore/vec.rs:1755 for self.each |e| { ^~~~ /Users/alex/code/rust2/src/libcore/vec.rs:1757:8: 1757:9 note: impure due to access to impure function /Users/alex/code/rust2/src/libcore/vec.rs:1757 } ^ error: aborting due to previous error ``` I also didn't delve too much into removing mutable fields with `Cell` or `transmute` and friends.
2013-04-08Removing no longer needed unsafe blocksAlex Crichton-47/+33