[R] exactly representable numbers

Robin Hankin r.hankin at noc.soton.ac.uk
Mon Sep 11 17:01:21 CEST 2006


Hi Duncan


[snip]

On 11 Sep 2006, at 12:12, Duncan Murdoch wrote:

> Here's my version:  not tested too much.
>
> f <- function(x) {
>    u <- x
>    l <- 0
>    mid <- u/2
>    while (l < mid && mid < u) {
>      if (x < x + mid) u <- mid
>      else l <- mid
>      mid <- (l + u)/2
>    }
>    u
> }
>



thanks for this.  Wouldn't it be a good idea to have some function
that returns "the smallest exactly representable number strictly  
greater than x"?

Or does this exist already?



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



More information about the R-help mailing list