[R] C module causing rounding errors?
Duncan Murdoch
murdoch.duncan at gmail.com
Fri Jul 9 12:18:45 CEST 2010
Joseph N. Paulson wrote:
> Hi all!
>
> I am currently writing a C-module for a for loop in which I permute columns
> in a matrix (bootstrapping) and I send a couple of variables into C
> initially. All of it is working, except the initial values I send to R are
> rounded/truncated (I believe rounded).
>
> I am using a 32 bit machine to compile, I am using (I believe) 32 bit R....
>
> While debugging I print the values I am sending to C, and then I print the
> same values using Rprintf and the number gets rounded to 10^-6, which is
> actually causing some errors for me. Is there any way to correct/prevent the
> error?
>
>
> sample output from R
>
> [1,] 1.0000000
> [2,] 1.0256242
> [3,] 1.1826277
> [4,] -0.6937246
> [5,] 1.3633604
>
> sample output from C
> 1.000000
> 1.025624
> 1.182628
> 0.693725
> 1.363360
>
It looks as though you are confusing the display of numbers with their
internal values. R is printing 7 decimal places, C is printing 6. As
far as we can tell, that's the only difference.
Duncan Murdoch
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list