File tree 2 files changed +30
-8
lines changed
2 files changed +30
-8
lines changed Original file line number Diff line number Diff line change @@ -259,17 +259,39 @@ pure fn ge(x: float, y: float) -> bool { ret x >= y; }
259
259
/* Predicate: gt */
260
260
pure fn gt ( x : float , y : float ) -> bool { ret x > y; }
261
261
262
- /* Predicate: positive */
262
+ /*
263
+ Predicate: positive
264
+
265
+ Returns true if `x` is a positive number, including +0.0 and +Infinity.
266
+ */
263
267
pure fn positive ( x : float ) -> bool { ret x > 0. || ( 1. /x) == infinity ( ) ; }
264
268
265
- /* Predicate: negative */
269
+ /*
270
+ Predicate: negative
271
+
272
+ Returns true if `x` is a negative number, including -0.0 and -Infinity.
273
+ */
266
274
pure fn negative ( x : float ) -> bool { ret x < 0. || ( 1. /x) == neg_infinity ( ) ; }
267
275
268
- /* Predicate: nonpositive */
269
- pure fn nonpositive ( x : float ) -> bool { ret ! positive( x) ; }
276
+ /*
277
+ Predicate: nonpositive
278
+
279
+ Returns true if `x` is a negative number, including -0.0 and -Infinity.
280
+ (This is the same as `float::negative`.)
281
+ */
282
+ pure fn nonpositive ( x : float ) -> bool {
283
+ ret x < 0. || ( 1. /x) == neg_infinity ( ) ;
284
+ }
270
285
271
- /* Predicate: nonnegative */
272
- pure fn nonnegative ( x : float ) -> bool { ret ! negative( x) ; }
286
+ /*
287
+ Predicate: nonnegative
288
+
289
+ Returns true if `x` is a positive number, including +0.0 and +Infinity.
290
+ (This is the same as `float::positive`.)
291
+ */
292
+ pure fn nonnegative ( x : float ) -> bool {
293
+ ret x > 0. || ( 1. /x) == infinity ( ) ;
294
+ }
273
295
274
296
//
275
297
// Local Variables:
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ fn test_nonpositive() {
47
47
assert ( float:: nonpositive ( -1. ) ) ;
48
48
assert ( float:: nonpositive ( float:: neg_infinity ( ) ) ) ;
49
49
assert ( float:: nonpositive ( 1. /float:: neg_infinity ( ) ) ) ;
50
- // TODO: assert(!float::nonpositive(float::NaN()));
50
+ assert ( !float:: nonpositive ( float:: NaN ( ) ) ) ;
51
51
}
52
52
53
53
#[ test]
@@ -58,5 +58,5 @@ fn test_nonnegative() {
58
58
assert ( !float:: nonnegative ( -1. ) ) ;
59
59
assert ( !float:: nonnegative ( float:: neg_infinity ( ) ) ) ;
60
60
assert ( !float:: nonnegative ( 1. /float:: neg_infinity ( ) ) ) ;
61
- // TODO: assert(!float::nonnegative(float::NaN()));
61
+ assert ( !float:: nonnegative ( float:: NaN ( ) ) ) ;
62
62
}
You can’t perform that action at this time.
0 commit comments