[R] Bug in "is" ?
Peter Dalgaard
P.Dalgaard at biostat.ku.dk
Mon Sep 29 11:48:23 CEST 2008
Stefan Evert wrote:
> Hi everyone!
>
> Sorry for taking an already overlong discussion thread slightly off-
> topic, but ...
>
>
>> quote:
>> No doubt, 7.0 is integer in math. But if people can write 7 why
>> people need to write 7.0 (I do not see any reason to do this).
>> endquote
>>
>
>
>> What is true in mathematics is not necessarily true in R.
>>
>
> ... am I the only one who thinks that the integer 7 is something
> entirely different from the real number 7.0? (The latter most likely
> being an equivalence class of sequences of rational numbers, but that
> depends on your axiomatisation of real numbers.) Integers can be
> embedded in the set of real numbers, but that doesn't make them the
> same mathematically.
>
Several people have tried to make that point (or something very
similar), but it doesn't seem to take.
It might get clearer if taken one step up: is.double(-1+0i) is not true
either, even though the real line is cleanly embedded in complex space,
-1+0i is not the same as -1. For instance, you can take the square root
of the former but not the latter.
With integers it is less clear that there is a difference in R, but it
has been mentioned that you can get overflows from adding and multipying
integers which you dont get with reals. In other programming languages,
division of integers is integer division and many a fledgling C
programmer has found the hard way that (2/3)*x is different from 2*x/3.
> So the original complaint should really have said that is.integer()
> doesn't do what a naive user (i.e. someone without a background in
> computer science or maths) might expect it to do. :-)
>
> That said, I've fallen into the same trap more than once, and
> painfully, myself (often in connection with MySQL).
>
>
> Best wishes, and with a tiny grain of salt,
> Stefan Evert
>
> [ stefan.evert at uos.de | http://purl.org/stefan.evert ]
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list