momentjs - JavaScript - Detecting the difference between positive zero and negative zero -


this question has answer here:

i using momentjs calculate difference between 2 times. weird thing library difference between today , today 0. difference between today , tomorrow -0.

my question is, how differentiate between 0 , -0. seems javascript treats them same.

so example if write following code:

if (tomorrow === -0)     console.log('it tomorrow!'); else if (tomorrow === 0)     console.log('it today!'); 

here's example on jsfiddle how handles returned values (i in australia depending on in word may have adjust today , tomorrow dates)

1/val > 0 want. returns true positive , false negative.

this works because 1/-0 returns negative infinity, , 1/0 returns positive infinity, comparable. 1/val == infinity.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -