How does the R-gmp package treat "Inf"? -


i noticed following when running gmp r :

rgames> log2(inf) [1] inf rgames> log2(as.bigz(inf)) [1] 8000 

what's happening here? or gmp language (or gmp::log2.bigz method) not support concept of "inf" ?

edit: josh's comment correct: it's not log2 function per se rather fact as.bigz appears convert inf 2^8000 bigz integer. changed title match.

btw, there's this:

rgames> log2(-inf) [1] nan warning message: nans produced  rgames> log2(as.bigz(-inf)) [1] nan 

edit: stupid. log2(negative_anything) nan

but,

rgames> log2(-as.bigz(-inf)) [1] 8000 

fits josh's answer.

posting josh's detective work him, per request:

if download sources gmp, , search "inf" in $gmp-home$/src/bigintegerr.cc, you'll find following lines:

/// new: numeric '+- inf' give +- "large" instead of na 

and bit later

else { // dj +- inf : use large ( = +- 2 ^ 80000 -- arbitrarily ) 

my guess since gmp library doesn't have concept/representation of inf, r package authors had make decision how pass on user-supplied inf values external library. looks used convert inf na, , convert 2^80000.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -