From gmail at kubism.ku.dk  Sat Feb 16 19:05:15 2008
From: gmail at kubism.ku.dk (gmail at kubism.ku.dk)
Date: Sat, 16 Feb 2008 19:05:15 +0100 (CET)
Subject: [Rd] Arithmetic bug? (found when use POSIXct) (PR#10776)
Message-ID: <20080216180515.6EB6D2834619@mail.pubhealth.ku.dk>

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)
gmail at kubism.ku.dk