Browse thread
exception safety / RAII ?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Damien Doligez <damien.doligez@i...> |
| Subject: | Re: [Caml-list] Re: exception safety / RAII ? |
On Mar 8, 2005, at 22:56, Oliver Bandel wrote: > P.S.: I tried Random.float max_float and it seems to be always between > 1.<something> * 10^307 ... 1.<something> * 10^308 > Is this a problem of initialization, or a problem of the > Random-algorithm, > or a kind of strange (?) behaviour of a random walk? I've seen some 10^306 too. If you think about it, 99% of the reals between 0 and 10^308 are in the 10^306..10^308 range. But it's true that there is a "problem": roughly speaking, Random.float simply takes a (uniformly distributed) real between 0 and 1, rounds it to the nearest float, and multiplies by its argument. So in your case it will never return a number greater than 0 and smaller than epsilon * max_float. It's not clear what the spec should be anyway. If you want a uniform distribution on the real interval and rounding to the nearest float, then the missing result range has a vanishingly small probability anyway. If you want a uniform distribution on the (finite) set of floats in the interval, you will get really counter-intuitive results and a function that cannot be used for physical simulations. -- Damien