@@ -44,6 +44,13 @@ pub trait Round {
44
44
pure fn fract ( & self ) -> Self ;
45
45
}
46
46
47
+ pub enum RoundMode {
48
+ RoundDown ,
49
+ RoundUp ,
50
+ RoundToZero ,
51
+ RoundFromZero
52
+ }
53
+
47
54
/**
48
55
* Cast a number the the enclosing type
49
56
*
@@ -82,13 +89,6 @@ pub trait NumCast {
82
89
pure fn to_float ( & self ) -> float ;
83
90
}
84
91
85
- pub enum RoundMode {
86
- RoundDown ,
87
- RoundUp ,
88
- RoundToZero ,
89
- RoundFromZero
90
- }
91
-
92
92
pub trait ToStrRadix {
93
93
pub pure fn to_str_radix ( & self , radix : uint ) -> ~str ;
94
94
}
@@ -99,62 +99,6 @@ pub trait FromStrRadix {
99
99
100
100
// Generic math functions:
101
101
102
- /// Dynamically calculates the value `inf` (`1/0`).
103
- /// Can fail on integer types.
104
- #[ inline( always) ]
105
- pub pure fn infinity < T : One +Zero +Div < T , T > > ( ) -> T {
106
- let _0: T = Zero :: zero ( ) ;
107
- let _1: T = One :: one ( ) ;
108
- _1 / _0
109
- }
110
-
111
- /// Dynamically calculates the value `-inf` (`-1/0`).
112
- /// Can fail on integer types.
113
- #[ inline( always) ]
114
- pub pure fn neg_infinity < T : One +Zero +Div < T , T > +Neg < T > > ( ) -> T {
115
- let _0: T = Zero :: zero ( ) ;
116
- let _1: T = One :: one ( ) ;
117
- - _1 / _0
118
- }
119
-
120
- /// Dynamically calculates the value `NaN` (`0/0`).
121
- /// Can fail on integer types.
122
- #[ inline( always) ]
123
- pub pure fn NaN < T : Zero +Div < T , T > > ( ) -> T {
124
- let _0: T = Zero :: zero ( ) ;
125
- _0 / _0
126
- }
127
-
128
- /// Returns `true` if `num` has the value `inf` (`1/0`).
129
- /// Can fail on integer types.
130
- #[ inline( always) ]
131
- pub pure fn is_infinity < T : One +Zero +Eq +Div < T , T > > ( num : & T ) -> bool {
132
- ( * num) == ( infinity :: < T > ( ) )
133
- }
134
-
135
- /// Returns `true` if `num` has the value `-inf` (`-1/0`).
136
- /// Can fail on integer types.
137
- #[ inline( always) ]
138
- pub pure fn is_neg_infinity < T : One +Zero +Eq +Div < T , T > +Neg < T > > ( num : & T )
139
- -> bool {
140
- ( * num) == ( neg_infinity :: < T > ( ) )
141
- }
142
-
143
- /// Returns `true` if `num` has the value `NaN` (is not equal to itself).
144
- #[ inline( always) ]
145
- pub pure fn is_NaN < T : Eq > ( num : & T ) -> bool {
146
- ( * num) != ( * num)
147
- }
148
-
149
- /// Returns `true` if `num` has the value `-0` (`1/num == -1/0`).
150
- /// Can fail on integer types.
151
- #[ inline( always) ]
152
- pub pure fn is_neg_zero < T : One +Zero +Eq +Div < T , T > +Neg < T > > ( num : & T ) -> bool {
153
- let _1: T = One :: one ( ) ;
154
- let _0: T = Zero :: zero ( ) ;
155
- * num == _0 && is_neg_infinity ( & ( _1 / * num) )
156
- }
157
-
158
102
/**
159
103
* Calculates a power to a given radix, optimized for uint `pow` and `radix`.
160
104
*
0 commit comments