Yes, divide by it. 1 / +0.0f
is +Infinity
, but 1 / -0.0f
is -Infinity
. It's easy to find out which one it is with a simple comparison, so you get:
if (1 / x > 0)
// +0 here
else
// -0 here
(this assumes that x
can only be one of the two zeroes)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…