More pseudo random number generators for calculators
07-09-2020, 11:19 AM
Post: #4
 Albert Chan Senior Member Posts: 2,000 Joined: Jul 2018
RE: More pseudo random number generators for calculators
Hi, Namir

Some algorithms you tested might get stuck, even with non-zero fractional part guess

Example, say with 12 digits calculator:

r = 0.999 999 999
r = frac(997/r) ﻿ ﻿ ﻿ ﻿ → r = frac(997.000000 997000000 997000000 ...) = .000 000 997
r = frac(997/r) ﻿ ﻿ ﻿ ﻿ → r = 0
r = frac(997/r) ﻿ ﻿ ﻿ ﻿ → r = NaN

To avoid rounding errrors like above, multiply based versions is safer.
With 15 digits internal precision, and 3 digits factor k, r = frac(k*r) is guaranteed exact.

This may be why baseline use r = frac(997*r)
 « Next Oldest | Next Newest »

 Messages In This Thread More pseudo random number generators for calculators - Namir - 07-08-2020, 02:19 PM RE: More pseudo random number generators for calculators - Erik-M - 07-08-2020, 07:51 PM RE: More pseudo random number generators for calculators - ttw - 07-09-2020, 03:45 AM RE: More pseudo random number generators for calculators - Namir - 07-10-2020, 11:25 PM RE: More pseudo random number generators for calculators - Namir - 07-15-2020, 06:12 AM RE: More pseudo random number generators for calculators - Albert Chan - 07-09-2020 11:19 AM RE: More pseudo random number generators for calculators - Namir - 07-09-2020, 07:35 PM RE: More pseudo random number generators for calculators - Gene - 07-09-2020, 09:15 PM RE: More pseudo random number generators for calculators - Namir - 07-09-2020, 09:45 PM RE: More pseudo random number generators for calculators - ttw - 07-09-2020, 01:42 PM RE: More pseudo random number generators for calculators - ttw - 07-13-2020, 03:00 PM

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