From ggrothendieck at gmail.com  Sat Feb 16 19:42:16 2008
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Sat, 16 Feb 2008 13:42:16 -0500
Subject: [Rd] Arithmetic bug? (found when use POSIXct) (PR#10776)
In-Reply-To: <20080216180515.6EB6D2834619@mail.pubhealth.ku.dk>
References: <20080216180515.6EB6D2834619@mail.pubhealth.ku.dk>
Message-ID: <971536df0802161042r46f4dd8dqe164c05f3360f399@mail.gmail.com>

See FAQ 7.31 or explain what you believe to be the problem.

On Feb 16, 2008 1:05 PM,  <gmail at kubism.ku.dk> wrote:
> Full_Name: Bo Zhou
> Version: 2.6.1 (2007-11-26)
> OS: Windows XP
> Submission from: (NULL) (207.237.54.242)
>
>
> Hi,
>
> I found an arithmetic problem when I'm doing something with POSIXct
> The code to reproduce it is as follows (This is the recommended way of finding
> out time zone difference on R News 2004-1 Page 32 URL
> http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf)
>
> a=Sys.time()
> b<-as.POSIXct(format(a,tz="GMT"))
> a-b
> unclass(a)
> unclass(b)
> unclass(a)-unclass(b)
> as.numeric(a)
> as.numeric(b)
> as.numeric(a)-as.numeric(b)
>
> The result on my machine
>
> > a=Sys.time()
> > b<-as.POSIXct(format(a,tz="GMT"))
> > a-b
> Time difference of -4.999969 hours
> > unclass(a)
> [1] 1203184447
> > unclass(b)
> [1] 1203202447
> attr(,"tzone")
> [1] ""
> > unclass(a)-unclass(b)
> [1] -17999.89
> attr(,"tzone")
> [1] ""
> > as.numeric(a)
> [1] 1203184447
> > as.numeric(b)
> [1] 1203202447
> > as.numeric(a)-as.numeric(b)
> [1] -17999.89



[Rd] Arithmetic bug? (found when use POSIXct) (PR#10776)
Gabor Grothendieck