Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87071 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27999 invoked from network); 8 Jul 2015 10:07:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jul 2015 10:07:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=scott@paragonie.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=scott@paragonie.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain paragonie.com from 209.85.192.51 cause and error) X-PHP-List-Original-Sender: scott@paragonie.com X-Host-Fingerprint: 209.85.192.51 mail-qg0-f51.google.com Received: from [209.85.192.51] ([209.85.192.51:35470] helo=mail-qg0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/34-16503-546FC955 for ; Wed, 08 Jul 2015 06:07:01 -0400 Received: by qget71 with SMTP id t71so97183060qge.2 for ; Wed, 08 Jul 2015 03:06:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=9BmluTpUF59kD7U0wORdrHHJC4p0Oraz9WQXKgukSRs=; b=GOJ/5+QTO+WxjZPkAU2Me4GIAtgOiuUsFRjVZGa97FK8ix9LPfV0O35j9YFyWYP9C7 owrvWJ0y5B8p7gsHHu0C/zxFJyYKGtx18evQsjAWciPTq/NMOxbhy2x0DJEP+3zs13nZ y6MXgI6AnV/r4nWz9iirzG91s/CTdmAp2YLByv3PEx+q+Oieq9rINmjdzCwMSCqumpl9 Nzjs9ub5JksKIoA6yZbwKjBPYfFdQSdtNzUbX7DgZKkkgwYY9kGsVjjGwnS6UBThUO3E kSxHggdphHJszcnqHnIG3eN8e59Bsfvq5z5oDwFj58W1+VA1RLH7OJREPSxiZoNjesdH MZwA== X-Gm-Message-State: ALoCoQlm/uFnavgmuerI5IQYiiBe4Xv4UTEb1L1GZOKwmswBl8S69BJkgli/u43xTMPBDhxA41D2 MIME-Version: 1.0 X-Received: by 10.55.33.144 with SMTP id f16mr6769924qki.8.1436350018229; Wed, 08 Jul 2015 03:06:58 -0700 (PDT) Received: by 10.96.83.102 with HTTP; Wed, 8 Jul 2015 03:06:58 -0700 (PDT) X-Originating-IP: [71.47.14.165] In-Reply-To: References: Date: Wed, 8 Jul 2015 06:06:58 -0400 Message-ID: To: Nikita Popov Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] random_compat From: scott@paragonie.com (Scott Arciszewski) You're right, I misread that part of the documentation. Scott Arciszewski Chief Development Officer Paragon Initiative Enterprises On Wed, Jul 8, 2015 at 6:03 AM, Nikita Popov wrote: > On Wed, Jul 8, 2015 at 11:59 AM, Scott Arciszewski > wrote: >> >> Hi everyone, >> >> I'm working on a library to backport random_bytes() and random_int() >> into PHP 5. The effort is located on Github if anyone is interested: >> https://github.com/paragonie/random_compat >> >> My reason for this email is that I'm running into one compatibility >> issue that I don't think I can safely work around: If we let >> random_int() default to -PHP_INT_MAX and PHP_INT_MAX, then the >> difference between the two (used to calculate the range) will overflow >> into a float, which will lead to a loss of precision. >> >> My current compromise is to use -(PHP_INT_MAX/2) and PHP_INT_MAX/2, >> but I'm not sure if there's a better solution. > > > random_int() arguments don't have default values, you have to explicitly > pass both. (Of course you still have a problem if someone does pass them :) > > Nikita