From maechler at stat.math.ethz.ch  Fri Aug  7 09:29:51 2009
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Fri, 7 Aug 2009 09:29:51 +0200
Subject: [Rd] identical(0, -0)
In-Reply-To: <77EB52C6DD32BA4D87471DCD70C8D7000195E482@NA-PA-VBE03.na.tibco.com>
References: <AD9D63E5376FD84F89F5B2D3E32B4001166F17@MSGMROCLB2WIN.DMN1.FMR.COM>
	<3aaf1a030908061445r29235545i224e1acce3ffcd69@mail.gmail.com>
	<200908062200.n76M0Q19023996@definetti.ddns.uark.edu>
	<77EB52C6DD32BA4D87471DCD70C8D7000195E482@NA-PA-VBE03.na.tibco.com>
Message-ID: <19067.55279.295410.685264@stat.math.ethz.ch>

>>>>> William Dunlap <wdunlap at tibco.com>
>>>>>     on Thu, 6 Aug 2009 15:06:08 -0700 writes:

    >> -----Original Message----- From:
    >> r-help-bounces at r-project.org
    >> [mailto:r-help-bounces at r-project.org] On Behalf Of
    >> Giovanni Petris Sent: Thursday, August 06, 2009 3:00 PM
    >> To: milton.ruser at gmail.com Cc: r-help at r-project.org;
    >> Daniel.Gerlanc at geodecapital.com Subject: Re: [R] Why is 0
    >> not an integer?
    >> 
    >> 
    >> I ran an instant experiment...
    >> 
    >> > typeof(0) [1] "double" > typeof(-0) [1] "double" >
    >> identical(0, -0) [1] TRUE
    >> 
    >> Best, Giovanni

    > But 0.0 and -0.0 have different reciprocals

    >> 1.0/0.0
    >    [1] Inf
    >> 1.0/-0.0
    >    [1] -Inf

    > Bill Dunlap TIBCO Software Inc - Spotfire Division wdunlap
    > tibco.com

yes.  {finally something interesting in this boring thread !}
---> diverting to R-devel

In April, I've had a private e-mail communication with John
Chambers [father of S, notably S4, which also brought identical()]
and Bill about the topic,
where I had started suggesting that  R  should be changed such
that
    identical(-0. , +0.)
would return FALSE.
Bill did mention that it does so for (newish versions of) S+
and that he'd prefer that, too,
and John said

 >> I agree on having a preference for a bitwise comparison for
 >> identical()---that's what the name means after all.  But since
 >> someone implemented the numerical case as the C == it's probably
 >> going to be more hassle than it's worth to change it.  But we
 >> should make the implementation clear in the documentation.

so in principle, we all agreed that R's identical() should be
changed here, namely by using something like  memcmp() instead
of simple '==' ,  however we haven't bothered to actually 
*implement* this change.

I am currently testing a patch  which would lead to
identical(0, -0)  return FALSE.

Martin Maechler, ETH Zurich
	    
    >> > By the way:
    >> > 
    >> > Are there difference between -0 and 0?



[Rd] identical(0, -0)
Martin Maechler