Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #34916

Re: Will Math.random return 0.0?

Path csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Will Math.random return 0.0?
Date Sat, 16 Jul 2016 13:11:27 -0400
Organization A noiseless patient Spider
Lines 33
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>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Sat, 16 Jul 2016 17:11:35 -0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="2d081e2f7155c28005d4472f67c2f43d"; logging-data="1440"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/iw/uwMR41EQw6cmUfksl9"
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0
In-Reply-To <nmdoqg$o6a$1@news2.informatik.uni-stuttgart.de>
Cancel-Lock sha1:yIUK7tWIXu6VLivHppLyAHPwXME=
Xref csiph.com comp.lang.java.programmer:34916

Show key headers only | View raw


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


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