[Rd] 'is.integer' (PR#13671)
savicky at cs.cas.cz
Thu Apr 23 10:21:45 CEST 2009
On Wed, Apr 22, 2009 at 04:30:36PM -0400, Stavros Macrakis wrote:
> Now consider 1e40, which has the property
> that floor(x)==x==ceiling(x), which you might think characterizes an
> integer; but it also has the property that x+1 == x. Similarly for
> 1/3 * 1e40.
The number 1/3 * 1e40 is larger than 2^53 and every value of double type,
which is larger than 2^53, is an even integer. The number has at least 54
digits mathematically, but only the first 53 of them are stored, so the last
one is zero. Since rounding is done towards an even value, we get x+1 == x.
Double type is safe for integer values in the interval [-2^53, 2^53].
Inside this interval, basic arithmetic operations (+,-,*,/) on integers,
whose result is an integer mathematically, yield integer result also in
More information about the R-devel