G'day Brian, On Fri, 16 May 2008 19:28:59 +0100 (BST) Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
> 'numeric' is a class but not a type -- so I think the FAQ is wrongly > worded but the concept is well defined Though there may be multiple definitions. :-) Reading a bit in "R Language Definition" (yes, I am aware that it is a draft), 'numeric' seems to be also used as a mode. I guess this comes from S3, the mode (no pun intended) that I am still using and thinking in mostly, and that 'numeric' being a class came in with S4. And I notice that mode(1L) and class(1L) gives different results, the former returns "numeric" while the latter returns "integer". Hence, when I read "R's numeric type" in the FAQ, I take this as referring to those basic types that are of mode numeric, i.e. integer and real. I am not sure whether changing this to "R's object of mode 'numeric'" or "R's object class 'numeric'" will make the answer more readable/understandable. > But it does not say that all such numbers can be represented > exactly, and only some can. I am well aware that integers and reals can only hold "integers and fractions whose denominator is a power of 2" from a limited range; in particular, the former will not hold any fractions. However, given the discussion in Goldberg (which FAQ 7.31 points to) on changing from binary to decimal representation and back, I would expect that given any such number (within the appropriate range) in decimal representation, it would be transformed into the correct, exact binary representation. However, I also know that if I stumble across an example where this is not the case, I shall only complain after ensuring that documented behaviour is violated and that the FAQ not necessarily documents expected behaviour. I guess Duncan's answer said it all, at the extreme ends of the appropriate ranges surprises might lurk, but it would be considered a serious bug if R did not transform small integers into their exact binary representation. Cheers, Berwin ______________________________________________ R-help@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.