From savicky at cs.cas.cz  Mon Aug 10 19:31:49 2009
From: savicky at cs.cas.cz (Petr Savicky)
Date: Mon, 10 Aug 2009 19:31:49 +0200
Subject: [Rd] identical(0, -0)
In-Reply-To: <4A7FECCD.2010208@stats.uwo.ca>
References: <mailman.23.1249725606.24224.r-devel@r-project.org>
	<4A7D8E08.2070300@uottawa.ca> <20090810092141.GC10119@cs.cas.cz>
	<4A7FECCD.2010208@stats.uwo.ca>
Message-ID: <20090810173149.GB17502@cs.cas.cz>

On Mon, Aug 10, 2009 at 05:47:57AM -0400, Duncan Murdoch wrote:
> I wouldn't mind a "strict" option.   It would compare bit patterns, so 
> would distinguish +0 from -0, and different NaN values.

I think that a logical option "strict" in the above meaning could be
useful for debugging. The default may be FALSE.

On Mon, Aug 10, 2009 at 10:20:39AM -0400, Duncan Murdoch wrote:
> +0 and -0 are exactly equal, which is what identical is documented to be 
> testing.  They are not indistinguishable, and not identical in the 
> English meaning of the word, but they are identical in the sense of what 
> the identical() function is documented to test.
> 
> The cases where you want to distinguish between them are rare.  They 
> should not be distinguished in the default identical() test, any more 
> than different values of NaN should be distinguished (and identical() is 
> explicitly documented *not* to distinguish those).
[...]

The question, whether 0 and -0 are equal or not, is not clear, since
they have different reciprocals. However, i agree that distinguishing
the signs of zero is rarely useful. From this point of view, the
default FALSE seems to be acceptable.

For completeness, let me also add an argument that it would not be too
harmful, if the default is TRUE. I think that it is quite rare to have
two larger numerical structures, which match up to the last bits in all
numbers, but have a different sign of some zero. Matching all bits
almost requires that the two structures are obtained using the same
expressions for all components. Then, also the signs of zeros will
match. However, i may be wrong.

Petr.



[Rd] identical(0, -0)
Petr Savicky