[Rd] Arithmetic bug? (found when use POSIXct) (PR#10776)
ggrothendieck at gmail.com
Sun Feb 17 22:15:27 CET 2008
OK. Good point.
Note that that article was written 4 years ago
when R was at version 1.9 and POSIXt did not fully support
subseconds. At that time, POSIXct could represent subseconds
internally but it was not used as POSIXlt did not yet support it
and that and the associated digits.sec option did not come until
R version 2.3, released two years after the article was written.
Try setting the digits.secs option before you run the command
> options(digits.secs = 3)
> dp <- Sys.time()
Time difference of -5 hours
On Feb 17, 2008 3:50 PM, <bozhou1981 at hotmail.com> wrote:
> Hi Gabo,
> FAQ 7.31 does not apply to this. "numeric" in R is 64bit which is large eno=
> ugh to handle this.
> figured out the cause is that Sys.time() gives millisecond value while
> b<-as.POSIXct(format(a,tz=3D"GMT")) cuts off that part.=20
> Then of course a-b is not 5 hours!
> Do it again with "options(digits=3D22)" and you will see what actually happ=
> ened there.
> The recommended code from R News is not aware the truth that POSIXlt can re=
> present sub-second time.
> Helping your favorite cause is as easy as instant messaging.=A0You IM, we g=
> [[alternative HTML version deleted]]
> R-devel at r-project.org mailing list
More information about the R-devel