Post Reply 
(11C) Random Prime Number Generator
10-22-2018, 09:11 AM
Post: #19
RE: (11C) Random Prime Number Generator
(10-22-2018 01:02 AM)Albert Chan Wrote:  It seems about 50% of the time, N * RAN# = N rounding bug will not occur.

I wouldn't call this a bug. After all the result is rounded correctly.
It really depends on the mantissa \(m\) of the number.
If \(1 < m \leqslant 5\) then the result is rounded up.
Otherwise it's rounded down.

Obviously I wasn't aware of this fact when I wrote the program.
So, props to Dieter for pointing that out.

A similar thing happens with 0.9999999998.
Here the result is rounded up if \(1 < m \leqslant 2.5\).

And then with 0.9999999997 the result is rounded up if \(1 < m \leqslant 1.666666666\).
Finally with 0.9999999996 the result is rounded up if \(1 < m \leqslant 1.25\).

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(11C) Random Prime Number Generator - Gamo - 10-20-2018, 01:08 PM
RE: (11C) Random Prime Number Generator - Thomas Klemm - 10-22-2018 09:11 AM



User(s) browsing this thread: 1 Guest(s)