Brendan Zabarauskas
6fa054df96
Use borrowed pointers for Integer methods
...
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-25 08:20:00 +10:00
Brendan Zabarauskas
024bf2ec72
Rename Natural to Integer
...
'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-25 08:20:00 +10:00
Brendan Zabarauskas
d4868ee740
Use #[cfg(not(stage0))] to exclude items from stage0
...
As requested on the mailing list: https://mail.mozilla.org/pipermail/rust-dev/2013-April/003713.html
2013-04-25 08:20:00 +10:00
Brendan Zabarauskas
03932f0b84
Move impls of Num
out of core::num and clean up imports
2013-04-25 08:20:00 +10:00
Brendan Zabarauskas
f39152e07b
Implement Natural trait
...
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-24 14:18:01 +10:00
Brendan Zabarauskas
aef249056e
Implement Signed and Unsigned traits and remove related predicate functions
2013-04-24 12:46:26 +10:00
Brendan Zabarauskas
01eb5e8ad3
Rename Div operator trait to Quot and Modulo operator trait to Rem
2013-04-22 01:58:53 +10:00
Brendan Zabarauskas
a7f6ec8542
Use assert_eq! instead of assert! and remove extraneous parentheses
2013-04-19 01:37:21 +10:00
Brendan Zabarauskas
0615fddd80
Remove unnecessary enclosing modules for NumCast impls
2013-04-14 05:27:32 +10:00
Brendan Zabarauskas
c4685477e0
Consolidate tests of numeric operations
2013-04-14 02:53:00 +10:00
Brendan Zabarauskas
ce6ee7bb04
Restore Num trait
...
This restores the trait that was lost in 216e85fadf
. 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-14 02:19:35 +10:00
Brendan Zabarauskas
fde6995229
Remove trailing whitespace
2013-04-14 01:25:56 +10:00
Brendan Zabarauskas
947ba206e1
Add a test to show how NumCast can be used in type parameters
2013-04-14 01:14:02 +10:00
Brendan Zabarauskas
353ce872e2
Generate NumCast impls and tests using macros
2013-04-14 01:14:02 +10:00
Brendan Zabarauskas
3ffd735b45
Clarify purpose of NumCast trait
2013-04-14 01:14:02 +10:00
Patrick Walton
1e91595520
librustc: Remove fail_unless!
2013-03-29 16:39:08 -07:00
Alex Crichton
be57d745d2
Removing unused imports
2013-03-28 23:56:46 -04:00
Patrick Walton
be9bddd463
libcore: Remove pure
from libcore. rs=depure
2013-03-22 10:29:17 -07:00
Patrick Walton
4634f7edae
librustc: Remove all uses of static
from functions. rs=destatic
2013-03-22 10:27:39 -07:00
Patrick Walton
d7e74b5e91
librustc: Convert all uses of assert
over to fail_unless!
2013-03-07 22:37:57 -08:00
Alex Crichton
dfb5c10dea
Remove unused imports throughout src/
2013-03-04 12:27:01 -05:00
Patrick Walton
a3f728238b
librustc: Forbid chained imports and fix the logic for one-level renaming imports
2013-03-02 16:49:30 -08:00
Patrick Walton
bf2a225c0b
librustc: Separate most trait bounds with '+'. rs=plussing
2013-02-20 21:14:20 -08:00
Marvin Löbel
3edc7c0b9c
Removed generic infinity, NaN and negative zero functions
...
Removed Round impl for integers
2013-02-15 05:46:07 +01:00
Marvin Löbel
adac6cb5c6
Moved numeric string conversion functions into own module
2013-02-15 03:29:36 +01:00
Patrick Walton
216e85fadf
libcore: Move the numeric operations out of Num. r=brson
...
Sadly I could not use trait inheritance due to a type parameter substitution
bug.
2013-02-14 08:14:01 -08:00
Nick Desaulniers
4445b38df2
Remove die!, raplace invocations with fail! Issue #4524 pt 3
2013-02-13 17:01:32 -08:00
Graydon Hoare
e5aa399e0d
rustc and std: teach about #[bench], modernize to use quote_expr! some.
2013-02-13 11:46:25 -08:00
Graydon Hoare
73280b0472
core: add abs to num.
2013-02-13 11:46:25 -08:00
Brendan Zabarauskas
48b2141b83
Add NumCast trait for generic numeric type casts
2013-02-11 12:33:05 +11:00
Marvin Löbel
974d5ac1e0
Fixed errors resulting from rebase.
2013-02-03 15:37:25 -08:00
Marvin Löbel
af4972f3ce
Fixed fmt!
, tests, doc-tests.
2013-02-03 15:37:25 -08:00
Marvin Löbel
98445d95d4
Removed wrong/wip doc
2013-02-03 15:37:25 -08:00
Marvin Löbel
5b0335ec8e
Added generic string <-> number conversion functions to core::num.
...
They unify the different implementations that exists in int-template.rs, uint-template.rs and float.rs into one pair of functions, which are also in principle usable for anything that implements the necessary numeric traits. Their usage is somewhat complex due to the large amount of arguments each one takes, but as they're not meant to be used directly that shouldn't be a problem.
2013-02-03 15:37:24 -08:00
Marvin Löbel
bb9c3ed876
Added some generic number functions to core::num
...
Also fixes previous commit not compiling due to not finding Option.
2013-02-03 15:37:24 -08:00
Marvin Löbel
d13b23f37e
Added ToStrRadix and FromStrRadix traits
2013-02-03 15:37:24 -08:00
Marvin Löbel
96f0512a45
Added Round trait to core
2013-02-03 15:37:23 -08:00
Marvin Löbel
40f0b45f8e
Moved all numeric modules in core into own directory
...
Reason: Better grouping of related modules, future-proving for a more extensive math library.
2013-02-03 15:37:23 -08:00