@@ -105,38 +105,52 @@ pub const infinity: f32 = 1.0_f32/0.0_f32;
105105
106106pub const neg_infinity: f32 = -1.0_f32 /0.0_f32 ;
107107
108+ #[ inline( always) ]
108109pub pure fn is_NaN ( f : f32 ) -> bool { f != f }
109110
111+ #[ inline( always) ]
110112pub pure fn add ( x : f32 , y : f32 ) -> f32 { return x + y; }
111113
114+ #[ inline( always) ]
112115pub pure fn sub ( x : f32 , y : f32 ) -> f32 { return x - y; }
113116
117+ #[ inline( always) ]
114118pub pure fn mul ( x : f32 , y : f32 ) -> f32 { return x * y; }
115119
120+ #[ inline( always) ]
116121pub pure fn div ( x : f32 , y : f32 ) -> f32 { return x / y; }
117122
123+ #[ inline( always) ]
118124pub pure fn rem ( x : f32 , y : f32 ) -> f32 { return x % y; }
119125
126+ #[ inline( always) ]
120127pub pure fn lt ( x : f32 , y : f32 ) -> bool { return x < y; }
121128
129+ #[ inline( always) ]
122130pub pure fn le ( x : f32 , y : f32 ) -> bool { return x <= y; }
123131
132+ #[ inline( always) ]
124133pub pure fn eq ( x : f32 , y : f32 ) -> bool { return x == y; }
125134
135+ #[ inline( always) ]
126136pub pure fn ne ( x : f32 , y : f32 ) -> bool { return x != y; }
127137
138+ #[ inline( always) ]
128139pub pure fn ge ( x : f32 , y : f32 ) -> bool { return x >= y; }
129140
141+ #[ inline( always) ]
130142pub pure fn gt ( x : f32 , y : f32 ) -> bool { return x > y; }
131143
132144// FIXME (#1999): replace the predicates below with llvm intrinsics or
133145// calls to the libmath macros in the rust runtime for performance.
134146
135147/// Returns true if `x` is a positive number, including +0.0f320 and +Infinity
148+ #[ inline( always) ]
136149pub pure fn is_positive ( x : f32 ) -> bool
137150 { return x > 0.0f32 || ( 1.0f32 /x) == infinity; }
138151
139152/// Returns true if `x` is a negative number, including -0.0f320 and -Infinity
153+ #[ inline( always) ]
140154pub pure fn is_negative ( x : f32 ) -> bool
141155 { return x < 0.0f32 || ( 1.0f32 /x) == neg_infinity; }
142156
@@ -145,6 +159,7 @@ pub pure fn is_negative(x: f32) -> bool
145159 *
146160 * This is the same as `f32::is_negative`.
147161 */
162+ #[ inline( always) ]
148163pub pure fn is_nonpositive ( x : f32 ) -> bool {
149164 return x < 0.0f32 || ( 1.0f32 /x) == neg_infinity;
150165}
@@ -154,21 +169,25 @@ pub pure fn is_nonpositive(x: f32) -> bool {
154169 *
155170 * This is the same as `f32::is_positive`.)
156171 */
172+ #[ inline( always) ]
157173pub pure fn is_nonnegative ( x : f32 ) -> bool {
158174 return x > 0.0f32 || ( 1.0f32 /x) == infinity;
159175}
160176
161177/// Returns true if `x` is a zero number (positive or negative zero)
178+ #[ inline( always) ]
162179pub pure fn is_zero ( x : f32 ) -> bool {
163180 return x == 0.0f32 || x == -0.0f32 ;
164181}
165182
166183/// Returns true if `x`is an infinite number
184+ #[ inline( always) ]
167185pub pure fn is_infinite ( x : f32 ) -> bool {
168186 return x == infinity || x == neg_infinity;
169187}
170188
171189/// Returns true if `x`is a finite number
190+ #[ inline( always) ]
172191pub pure fn is_finite ( x : f32 ) -> bool {
173192 return !( is_NaN ( x) || is_infinite ( x) ) ;
174193}
@@ -219,45 +238,63 @@ pub mod consts {
219238 pub const ln_10: f32 = 2.30258509299404568401799145468436421_f32 ;
220239}
221240
241+ #[ inline( always) ]
222242pub pure fn signbit ( x : f32 ) -> int {
223243 if is_negative ( x) { return 1 ; } else { return 0 ; }
224244}
225245
246+ #[ inline( always) ]
226247pub pure fn logarithm ( n : f32 , b : f32 ) -> f32 {
227248 return log2 ( n) / log2 ( b) ;
228249}
229250
230251#[ cfg( notest) ]
231252impl f32 : cmp:: Eq {
253+ #[ inline( always) ]
232254 pure fn eq ( & self , other : & f32 ) -> bool { ( * self ) == ( * other) }
255+ #[ inline( always) ]
233256 pure fn ne ( & self , other : & f32 ) -> bool { ( * self ) != ( * other) }
234257}
235258
236259#[ cfg( notest) ]
237260impl f32 : cmp:: Ord {
261+ #[ inline( always) ]
238262 pure fn lt ( & self , other : & f32 ) -> bool { ( * self ) < ( * other) }
263+ #[ inline( always) ]
239264 pure fn le ( & self , other : & f32 ) -> bool { ( * self ) <= ( * other) }
265+ #[ inline( always) ]
240266 pure fn ge ( & self , other : & f32 ) -> bool { ( * self ) >= ( * other) }
267+ #[ inline( always) ]
241268 pure fn gt ( & self , other : & f32 ) -> bool { ( * self ) > ( * other) }
242269}
243270
244271impl f32 : num:: Num {
272+ #[ inline( always) ]
245273 pure fn add ( & self , other : & f32 ) -> f32 { return * self + * other; }
274+ #[ inline( always) ]
246275 pure fn sub ( & self , other : & f32 ) -> f32 { return * self - * other; }
276+ #[ inline( always) ]
247277 pure fn mul ( & self , other : & f32 ) -> f32 { return * self * * other; }
278+ #[ inline( always) ]
248279 pure fn div ( & self , other : & f32 ) -> f32 { return * self / * other; }
280+ #[ inline( always) ]
249281 pure fn modulo ( & self , other : & f32 ) -> f32 { return * self % * other; }
282+ #[ inline( always) ]
250283 pure fn neg ( & self ) -> f32 { return -* self ; }
251284
285+ #[ inline( always) ]
252286 pure fn to_int ( & self ) -> int { return * self as int ; }
287+ #[ inline( always) ]
253288 static pure fn from_int( n: int ) -> f32 { return n as f32 ; }
254289}
255290
256291impl f32 : num:: Zero {
292+ #[ inline( always) ]
257293 static pure fn zero( ) -> f32 { 0.0 }
258294}
259295
260296impl f32 : num:: One {
297+ #[ inline( always) ]
261298 static pure fn one( ) -> f32 { 1.0 }
262299}
263300
0 commit comments