runif appears to give 31 bits of precision, but this isn't mentioned
in the documentation page. The R numeric type supports 53 digits of
precision, and other numeric functions (sin, etc.) give full-precision
results.  So I'd think that either runif should give full precision or
its documentation should mention this limitation.

#integers
table(runif(10000,-2^30,2^30) %% 1)
   0  0.5
4972 5028
#natural numbers
> table(runif(10000,0,2^31) %% 1)
   0  0.5
4956 5044
#fractions
table((r<-runif(10000,0,1)*2^31)-floor(r))
   0  0.5
5021 4979

______________________________________________
R-help@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.

Reply via email to