Skip to content
Prev 157494 / 398506 Next

Bug in "is" ?

Wacek Kusnierczyk wrote:
i also note that r *can* swallow the following (returning a non-integer
result):

sqrt(as.integer(2))

but it can't do the following (it returns NaN with a warning):

sqrt(as.integer(-1))
sqrt(as.double(-1))
sqrt(-1)

which is incoherent, in that there is an implicit type cast in the first
case, but not in the later ones.  and why not?
obviously, sage's gracefully computing sqrt(int(-1)) is a proof by
construction (for those who really need it) that r's design choice is
not the only possible (and, arguably, not the most intuitive and
practical, at this level of abstraction).

vQ