Skip to content

Commit d52191b

Browse files
mbrubeckbrson
authored andcommitted
---
yaml --- r: 6028 b: refs/heads/master c: 45d7777 h: refs/heads/master v: v3
1 parent d77c043 commit d52191b

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 000b2fe9a6b18cab1deee9579e8740d7c37a67b4
2+
refs/heads/master: 45d77779916a7af0b2b7656453e31eea9f4b3cfa

trunk/src/lib/float.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,39 @@ pure fn ge(x: float, y: float) -> bool { ret x >= y; }
259259
/* Predicate: gt */
260260
pure fn gt(x: float, y: float) -> bool { ret x > y; }
261261

262-
/* Predicate: positive */
262+
/*
263+
Predicate: positive
264+
265+
Returns true if `x` is a positive number, including +0.0 and +Infinity.
266+
*/
263267
pure fn positive(x: float) -> bool { ret x > 0. || (1./x) == infinity(); }
264268

265-
/* Predicate: negative */
269+
/*
270+
Predicate: negative
271+
272+
Returns true if `x` is a negative number, including -0.0 and -Infinity.
273+
*/
266274
pure fn negative(x: float) -> bool { ret x < 0. || (1./x) == neg_infinity(); }
267275

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+
}
270285

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+
}
273295

274296
//
275297
// Local Variables:

trunk/src/test/stdtest/float.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn test_nonpositive() {
4747
assert(float::nonpositive(-1.));
4848
assert(float::nonpositive(float::neg_infinity()));
4949
assert(float::nonpositive(1./float::neg_infinity()));
50-
// TODO: assert(!float::nonpositive(float::NaN()));
50+
assert(!float::nonpositive(float::NaN()));
5151
}
5252

5353
#[test]
@@ -58,5 +58,5 @@ fn test_nonnegative() {
5858
assert(!float::nonnegative(-1.));
5959
assert(!float::nonnegative(float::neg_infinity()));
6060
assert(!float::nonnegative(1./float::neg_infinity()));
61-
// TODO: assert(!float::nonnegative(float::NaN()));
61+
assert(!float::nonnegative(float::NaN()));
6262
}

0 commit comments

Comments
 (0)