R-alpha: wierdness with choose() and vector()

Gregory R. Warnes (warnes@biostat.washington.edu)
Wed, 4 Sep 1996 13:01:31 -0700 (PDT)


Date: Wed, 4 Sep 1996 13:01:31 -0700 (PDT)
From: "Gregory R. Warnes" <warnes@biostat.washington.edu>
To: r-testers <r-testers@stat.math.ethz.ch>
Subject: R-alpha: wierdness with choose() and vector()


I've noticed a bug with choose: It should return an exact _integer_ value,
but currently returns a _real_ which is only close to the correct integer.   
For instance: 

> choose(3,2)-3
[1] -4.440892e-16
> choose(4,2)-6
[1] 8.881784e-16

Since the value returned is not exact, you can get wierd things 
happening, for example when I tried using choose() with functions that 
call vector, I get:

> vector("character",choose(3,2))
[1] "" ""
> vector("character",3)
[1] "" "" ""

note that:

> as.integer(choose(3,2))
[1] 2

choose() should be modified to return an exact integer to avoid these 
problems.

Greg


-------------------------------------------------------------------------------
    Gregory R. Warnes          | It is high time that the ideal of success
warnes@biostat.washington.edu  |  be replaced by the ideal of service.
                               |                       Albert Einstein
-------------------------------------------------------------------------------

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-