Path: csiph.com!aioe.org!.POSTED!not-for-mail From: emf Newsgroups: comp.lang.javascript Subject: Re: Random numbers Date: Fri, 20 Oct 2017 20:32:31 -0400 Organization: Aioe.org NNTP Server Lines: 32 Message-ID: References: NNTP-Posting-Host: KQE17V6I+pklevNrq35dhw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 X-Notice: Filtered by postfilter v. 0.8.2 Content-Language: en-US Xref: csiph.com comp.lang.javascript:34152 On 2017-10-19 07:35, emf wrote: > I am wondering if there is a better (but still not too complicated) way > to generate random numbers then the Math.random(). My idea is to get the > microseconds, multiply them by, say 10000, bet the integer, and then the > modulus of that. Wouldn't that give more random numbers? > ' > Thanks, > > Eustace The discussion was quite interesting and it gave me leads to pursue. But here is a more specific question: would the following function provide *more* random results than the Math.random()? // returns a random number from 1 to top function random(top) { var now = new Date(); var hh = now.getHouera(); var mm = now.getMinutes(); var ss = now.getSeconds(); var ms = now.getMilliseconds(); var tim = (hh * 1440000) + (mm * 60000) + (ss * 1000) + ms; var rndm = (tim % top) + 1; return rndm; } Eustace -- It ain't me, babe - A radical reinterpretation http://emf.neocities.org/bd/itaintmebabe.html