Re:Negative Base
by pphysch on Thursday June 28, 2018 @02:48PM
(#17419444)
Are there common languages where -0 != +0? Or are you implying that this would be a good decision when creating a new language?
[ Parent
| on HN ]
Re:Negative Base
by kybernetikos on Thursday June 28, 2018 @07:29PM
(#17421316)
javascript:
> 1/(-0)
-Infinity
> 1/0
Infinity
> Object.is(0, -0)
false
Of course = doesn't actually test equality in javascript. == reports -0 as being equal to +0, but Object.is reports them as different.See now, I contest this particular defense because it groups together 'javascript' and 'good decision'.
basically every language with IEEE-754[1] compliance..!
I'd think that in all those languages, -0 == +0 tests true, though. In JavaScript even -0 === +0 tests true.
The only way to tell them apart in general is to divide by them. In some languages you might be able to type-pun and examine the bit pattern, or do things like Object.is() or whatnot.
But only when imposing a total ordering.
that’s not the case, in IEE754 floating point, zero is signed - i.e negative and positive zero are distinct values