Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80390 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43633 invoked from network); 12 Jan 2015 00:23:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jan 2015 00:23:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=leight@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=leight@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.171 as permitted sender) X-PHP-List-Original-Sender: leight@gmail.com X-Host-Fingerprint: 209.85.212.171 mail-wi0-f171.google.com Received: from [209.85.212.171] ([209.85.212.171:51243] helo=mail-wi0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 84/91-34383-A0413B45 for ; Sun, 11 Jan 2015 19:23:38 -0500 Received: by mail-wi0-f171.google.com with SMTP id bs8so11463952wib.4 for ; Sun, 11 Jan 2015 16:23:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=iWoX2JqHNcH3qgs0W3EH9P0KOujMBH8NA3QxXlUfGxY=; b=WqHGcQgQYDUTAIfrjMP+rluWiPMXkppjQpGZWWbhcwfyMIowXVMSFG8sIxR/yfhCgy ZlNhKFR029DXVNEwMoXxk+clvXPShXTZXe6rEQjshaqZrlRueu829aNzEAmeeml0aPfv cjEnpayWMRLfPwE9zyesXAR+ScSkt6MVQIUXO6u0NXl9gSkTtIEbinItSBRmxI4TQGDR HSbsKE0o5azydZgsQ6jiSf8XzX8aLYycICJW8rbdNFvEYZgdem/ENYX33902iUYURMoe xDxV8TbAUtt1DMTFpzlGShM5YQLHMZpbkWqDaKpXjaFV8cem08LI6AALxHkUSrRuuMWh 0eQQ== MIME-Version: 1.0 X-Received: by 10.194.200.234 with SMTP id jv10mr21009957wjc.110.1421022214458; Sun, 11 Jan 2015 16:23:34 -0800 (PST) Received: by 10.216.50.139 with HTTP; Sun, 11 Jan 2015 16:23:34 -0800 (PST) In-Reply-To: References: Date: Mon, 12 Jan 2015 00:23:34 +0000 Message-ID: To: Andrea Faulds Cc: PHP Internals List Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] rand(), mt_rand() and limits From: leight@gmail.com (Leigh) On 11 January 2015 at 22:12, Andrea Faulds wrote: > * Get rid of rand(), srand() and getrandmax() > * Rename mt_rand(), mt_srand() and mt_getrandmax() to rand(), srand(), and getrandmax() but add mt_* aliases for backwards-compatibility > * Make mt_srand() and srand() do nothing and produce a deprecation notice > * Use a 64-bit random number generation algorithm on 64-bit platforms (or invoke the 32-bit generator twice) > I have to object to removing the C stdlib rand(). mt_rand() is significantly slower and when I don't care about the "quality" of the random numbers the choice is obvious. Now if that means mt_rand() goes to rand(), and rand() goes to something like fast_rand(), that is fine, I don't care, I just don't think we should ditch the standard rand function. I do however think the default limits should be appropriate for the underlying platform, so 64 bit values returned by default on 64 bit platforms. The MT internal state is large enough for you to consume 64 bits at a time, no need to call it twice.