about summary refs log tree commit diff
path: root/src/libcore/num
AgeCommit message (Collapse)AuthorLines
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`.
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.