I'm looking through some of the code from the Google Closure Library and I found this line:
var isNegative = number < 0.0 || number == 0.0 && 1 / number < 0.0;
I've figured that the reason for such an initially strange looking sign-check is to identify -0
as negative, but is there any reason to use 0.0
instead of 0
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…