[R] exactly representable numbers

From: Robin Hankin <r.hankin_at_noc.soton.ac.uk>
Date: Mon 11 Sep 2006 - 08:52:03 GMT


Given a real number x, I want to know how accurately R can represent numbers near x.

In particular, I want to know the infinum of exactly representable numbers greater than x, and the supremum of exactly representable numbers
less than x. And then the interesting thing is the difference between these two.

I have a little function that does some of this:

f <- function(x,FAC=1.1){

   delta <- x
while(x+delta > x){

   delta <- delta/FAC


But this can't be optimal.

Is there a better way?

Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon Sep 11 18:59:20 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 11 Sep 2006 - 12:30:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.