Dear List,
I'm getting weird and unexpected behaviour using time and %%, or %/%. It's
likely I'm not appreciating the nuances of floating point arithmetic. Or it
could be a bug.
I'm running
R.version
_
platform x86_64-redhat-linux-gnu kernel 2.6.33.8-149.fc13.x86_64
Yes it is a floating point problem. January 2005 is slightly less than
2005, although the gap is somewhat bigger than .Machine$double.eps
time(junk) - 2005 # shows the gap is -2.2737e-13 for my machine
Try something this:
floor(time(junk) + 1e-10)
â â â â â â â â â
Steve,
thanks for the suggestion.
Alistair
On 01/09/10 11:20, Steve Taylor wrote:
Yes it is a floating point problem. January 2005 is slightly less than 2005,
although the gap is somewhat bigger than .Machine$double.eps
time(junk) - 2005 # shows the gap is -2.2737e-13 for my machine
Try
Steve is undoubtedly right about this being a floating point problem.
One comment I would make is that I think floor is a bit nicer for this,
both conceptually and for readability. Also you don't need a really
small value to add, half the sampling interval will work:
junk - ts(1:125,
On Tue, Aug 31, 2010 at 7:04 PM, Alistair Gray agg...@paradise.net.nz wrote:
Dear List,
I'm getting weird and unexpected behaviour using time and %%, or %/%. It's
likely I'm not appreciating the nuances of floating point arithmetic. Or it
could be a bug.
Here are two workarounds to get the
5 matches
Mail list logo