Displaying 1 result from an estimated 1 matches for "bsum2".
Did you mean:
sum2
2008 Apr 04
4
Arbitrary Precision Numbers
...ion(n) {
s <- 0
e <- floor(log10(2^n))
for (i in seq(e,0,-1)) {
s <- s + (((2^n) %/% 10^i) %% 10)
}
s
}
The above doesnt work, as I am using an integer modulus which has
insufficient precision. so I tried to coerce R to produce a full-precision
integer and sum the digits of that:
bsum2 <- function(n) {
s <- 0
strn <- formatC(2^n, format="fg")
sum(as.numeric(strsplit(strn,"")[[1]]))
}
This also doesnt seem to work. Is there another way I can do this in R?
Cheers
Rory
--
View this message in context: http://www.nabble.com/Arbitrary-Precision-Numbe...