How do I test if a number is greater than or equal to positive zero (+0
)?
Check whether its reciprocal is positive:
1 / value > 0
The reciprocal of +0
is positive Infinity
. The reciprocal of -0
is negative Infinity
.
UPDATE: The fact that diff
can return +0
or -0
doesn't seem to be documented, so I would hesitate to rely upon this behavior. Consider using isAfter
or isBefore
instead:
var d = '2014-12-28';
console.log(moment(d).isAfter(moment())); // Is the date tomorrow or later?
console.log(!moment(d).isBefore(moment(), 'day')); // Is the date today or later?