[Rd] a couple of things about ":"
Thomas Lumley
tlumley at u.washington.edu
Thu Apr 7 23:13:47 CEST 2005
On Thu, 7 Apr 2005, Liaw, Andy wrote:
> - It seems counter-intuitive to allow non-integer values as operand for ":".
> It also seems a bit odd that 1:2 returns something with storage.mode
> integer, whereas 0.5:2 gives doubles. Would it make sense to disallow
> non-integer operands to ":"? I can't think of a situation when non-integer
> operands for ":" would be good...
>
It depends on what you mean by non-integer. You certainly want to allow
operand with storage.mode "double". You might want to exclude
non-integers, but then you have problems with rounding:
a<-sqrt(2)
b<-sqrt(3)
(a^2):(b^2)
would fail. Allowing non-integers up to some tolerance would be needed,
but then there isn't much reason to forbid 0.5:2, and someone might have a
use for it.
-thomas
More information about the R-devel
mailing list