Using the following version of R:> R version 2.4.1 (2006-12-18)installed using apt-get on a Debian/Sarge AMD64 system with the following entry in /etc/apt/sources.lists: deb http://www.stats.bris.ac.uk/R/bin/linux/debian/ stable/ The problem: I'm seeing strange results in a integer calculation as follows:> choose(11,6) > [1] 462 > as.integer(choose(11,6)) > [1] 46111-choose-6 should return 462 of course. Other platforms and versions of R (R/Windows and R/32-bit Linux on an Ubuntu/Dapper box) give the correct result of 462 for the integer cast. What on earth is going on here? The values of 11 and 6 were stumbled-upon by accident and I haven't been able to find other example values which give a similar error. Two AMD64/Linux systems I have both display the above error, actually; I can't reproduce the error on any other platform/OS. All help/suggestions/appreciated! Dave. -- Dave Ewart davee at ceu.ox.ac.uk Computing Manager, Cancer Epidemiology Unit Cancer Research UK / Oxford University PGP: CC70 1883 BD92 E665 B840 118B 6E94 2CFD 694D E370 Get key from http://www.ceu.ox.ac.uk/~davee/davee-ceu-ox-ac-uk.asc N 51.7518, W 1.2016 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 191 bytes Desc: Digital signature Url : https://stat.ethz.ch/pipermail/r-help/attachments/20070320/81e9ebb6/attachment.bin
G'day Dave, On Tue, 20 Mar 2007 14:59:38 +0000 Dave Ewart <davee at ceu.ox.ac.uk> wrote:> All help/suggestions/appreciated!The calculations are done in floating point arithmetic, not integer arithmetic. From the help page on `choose' one might already guess so much, but reading "R-2.4.1/src/nmath/choose.c" definitely confirms this fact. Thus, your problem is covered by FAQ 7.31: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f HTH. Cheers, Berwin