Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34916
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Will Math.random return 0.0? |
| Date | 2016-07-16 13:11 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <nmdps7$1d0$1@dont-email.me> (permalink) |
| References | <rand-20160716162126@ram.dialup.fu-berlin.de> <nmdoj4$s2i$1@dont-email.me> <nmdoqg$o6a$1@news2.informatik.uni-stuttgart.de> |
On 7/16/2016 12:53 PM, Thomas Richter wrote:
> Am 16.07.2016 um 18:49 schrieb Eric Sosman:
>
>>
>>> Can we be sure that it will ever terminate?
>>
>> Yes.
>>
> No. A couple of well-understood "random" generators are simply of the form
>
> x_n = (x_{n-1} * a) mod b
... and Math.random() is *documented* to use a different generator.
The question of whether Math.random() will ever return 0.0 boils
down to whether two successive calls to Random#next() will return 27
and 26 (respectively) zero bits from among the 96 bits produced by
the *documented* base algorithm. I lack sufficient mathematical
prowess to say whether this is possible.
... but I claim, nonetheless, that Stefan's program will terminate:
- It may terminate on its own by generating 0.0, or
- Whoever is running it will tire of the exercise and stop it, or
- The JVM, O/S, hardware, or power will fail.
No matter which of these happens, the program will have terminated.
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Will Math.random return 0.0? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-16 12:49 -0400
Re: Will Math.random return 0.0? Thomas Richter <thor@math.tu-berlin.de> - 2016-07-16 18:53 +0200
Re: Will Math.random return 0.0? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-16 13:11 -0400
Re: Will Math.random return 0.0? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-17 08:06 -0400
Re: Will Math.random return 0.0? Arne Vajhøj <arne@vajhoej.dk> - 2016-07-16 14:17 -0400
csiph-web