In comp.lang.javascript message <
[email protected]
glegroups.com>, Thu, 18 Jan 2007 22:40:09, RobG <
[email protected]>
posted:
The resolution of a Date object is 1 ms. But the resolution of new
Date() depends on the system; the update interval can be considerably
greater.
But he should not be using parseInt(), which requires a string argument
unless the engine is over-clever. Math.floor() is right for the job,
and |0 is probably faster still.
Both are faster than new Date(), for me.
But if Math.random() is used, it is silly to use 1000; that reduces
randomness. Use 1e15 if an integer is required, or even
Math.floor(Math.random()*Math.pow(2, 53)).
Note : if the random generator effectively uses a 53-bit seed, which I
doubt, some such arithmetic might capture *all* its bits, guaranteeing a
2^53 cycle.
Test Math.random()*Math.pow(2, 53)
Math.random()*Math.pow(2, 54)
It's a good idea to read the newsgroup and its FAQ. See below.
--
(c) John Stockton, Surrey, UK.
[email protected] Turnpike v6.05 IE 6
FAQ <URL:
http://www.jibbering.com/faq/index.html>.
<URL:
http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:
http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.