octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Random number generation quirk


From: Philipp Kutin
Subject: Re: Random number generation quirk
Date: Mon, 10 Mar 2014 23:26:44 +0100

Alright... thinking further, to prevent the floating comparison, we
can simply determine the greatest integer n for which "(float)(2^-32 *
n) < 1.0" and plug that in. The result has been submitted [1] to the
patch tracker.

This leaves the rounding issue. In retrospect, I think it's not *that*
grave. As before, let d(n) denote the
difference between two consecutive numbers in [2^(-n-1), 2^-n) for n
>= 0. Since d(0) == 2^-24, d(i) == 2^(-24-i). The problem is greatest
where d(i) is twice the "base factor" 2^-32 -- this is the case for
i==8, or an interval of [2^-9, 2^-8) which itself has an extent of
1/512.

As can be seen from the test C file I posted at the patch tracker, I
tried playing around with setting the rounding mode dynamically. That
wasn't very fruitful though. First, this made the whole thing really
slow -- a full cycle was over a minute instead of ~20 seconds. Second
and more concerning, GCC doesn't seem to support doing this cleanly,
at least not in a way to satisfy the the C Standard. In this regard, I
found an amusing report [2] on the GCC bug tracker.

[1] https://savannah.gnu.org/patch/index.php?8389
[2] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34678

--Philipp


reply via email to

[Prev in Thread] Current Thread [Next in Thread]