Re: [Rd] Friday question: negative zero

2007-12-07 Thread Robin Hankin
Hello everyone On 1 Sep 2007, at 01:39, Duncan Murdoch wrote: > The IEEE floating point standard allows for negative zero, but it's > hard > to know that you have one in R. One reliable test is to take the > reciprocal. For example, > >> y <- 0 >> 1/y > [1] Inf >> y <- -y >> 1/y > [1] -Inf

Re: [Rd] Friday question: negative zero

2007-09-01 Thread Petr Savicky
On Sat, Sep 01, 2007 at 05:22:26PM -0600, Tony Plate wrote: > One place where I've been caught by -ve zeros is with unit tests. If > identical(-0, 0) returns FALSE, and the object storage doesn't preserve > -ve zeros, that can lead to test failures that are tricky to debug. > > However, it does

Re: [Rd] Friday question: negative zero

2007-09-01 Thread Tony Plate
One place where I've been caught by -ve zeros is with unit tests. If identical(-0, 0) returns FALSE, and the object storage doesn't preserve -ve zeros, that can lead to test failures that are tricky to debug. However, it doesn't look like that is too much a problem in the current incarnation o

Re: [Rd] Friday question: negative zero

2007-09-01 Thread Petr Savicky
On Fri, Aug 31, 2007 at 08:39:02PM -0400, Duncan Murdoch wrote: [snip] > The other day I came across one in complex numbers, and it took me a > while to figure out that negative zero was what was happening: > > > x <- complex(real = -1) > > x > [1] -1+0i > > 1/x > [1] -1+0i > > x^(1/3) >

Re: [Rd] Friday question: negative zero

2007-09-01 Thread Jeffrey Horner
[EMAIL PROTECTED] wrote: > > On 8/31/07, Duncan Murdoch <[EMAIL PROTECTED]> wrote: >> The IEEE floating point standard allows for negative zero, but it's hard >> to know that you have one in R. One reliable test is to take the >> reciprocal. For example, >> >> > y <- 0 >> > 1/y >> [1] Inf >>

Re: [Rd] Friday question: negative zero

2007-08-31 Thread deepayan . sarkar
On 8/31/07, Duncan Murdoch <[EMAIL PROTECTED]> wrote: > The IEEE floating point standard allows for negative zero, but it's hard > to know that you have one in R. One reliable test is to take the > reciprocal. For example, > > > y <- 0 > > 1/y > [1] Inf > > y <- -y > > 1/y > [1] -Inf > >

Re: [Rd] Friday question: negative zero

2007-08-31 Thread Steven McKinney
Seems the same on this Apple Mac OSX platform: > y <- 0 > 1/y [1] Inf > y <- -y > 1/y [1] -Inf > x <- complex(real = -1) > x [1] -1+0i > 1/x [1] -1+0i > x^(1/3) [1] 0.5+0.8660254i > (1/x)^(1/3) [1] 0.5-0.8660254i > sessionInfo() R version 2.5.1 (2007-06-27) powerpc-apple-darwin8.9.1 locale: en

Re: [Rd] Friday question: negative zero

2007-08-31 Thread Gabor Grothendieck
On 8/31/07, Duncan Murdoch <[EMAIL PROTECTED]> wrote: > The IEEE floating point standard allows for negative zero, but it's hard > to know that you have one in R. One reliable test is to take the > reciprocal. For example, > > > y <- 0 > > 1/y > [1] Inf > > y <- -y > > 1/y > [1] -Inf > > The