Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111036 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 51217 invoked from network); 16 Jul 2020 08:58:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Jul 2020 08:58:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9DBAB1804DB for ; Thu, 16 Jul 2020 00:51:41 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 16 Jul 2020 00:51:41 -0700 (PDT) Received: by mail-lj1-f170.google.com with SMTP id h19so6006323ljg.13 for ; Thu, 16 Jul 2020 00:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8WyBbQd52KtHgHJmaVldohTFeNlPZHMB0cTqgChjMiU=; b=bnNBTCFyB+4tNYfS4KzcBPOPBpUsYgYfywXmnIWmeVNX7h5WUGg/5UNiN3wuhqBQ5S ZmWL92VBOBK4z+AzFtpUu0sR5FdxaH8LpcMm5kGBUn6aMd2kVxoEPV1V7cUSl1jy22/h Ja4wVmI95yVxk6MoT/zB0intsMTseCyadba42ECuvRpf5k8CL2JtQsXaLTRdRbcoVqda weRlnuvZMdC2f93A0H4l3bhfzE+wmX5raa32lwH+8Wd7je/5pNcVFduIw2KhjbiA4cTb 5DZ3LB7teefgd3r0U//KsYQwbpGUpL57bBm6qxTBYGiZnKZ/PFfcGrLCN7BFXWdcmWJ8 EKnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8WyBbQd52KtHgHJmaVldohTFeNlPZHMB0cTqgChjMiU=; b=N5Wo/EMBAcheJHnImYbe5R3EmVelnLh6tuGRv6EQZQTu8hk4OqAH8EUM9GUKkrSCwZ bUbQfhyw48Rbg6JLIWcnaIe1cruHIhNNR14uN7LhWfmt4jET095T52T49mKsxE3OpshD fBedfB1Hv9FOxuRPINRw/2NhNwJH1tJE1UwLuW95zgWq7LmlcoSiIgU494ehNbt10FVc C/0X68APSDl5tZCn2qYKefjYEzXxjSrN1AgGdf9F93mxmI8iSTfZJDLHuHTJwy20ImcT 1Z3XZdEhEg8NYRR61HwtRDkCTQ/P40OpVls/IOmyGhe8CwgkARJk0jHh4bnHU32islUj W8KQ== X-Gm-Message-State: AOAM532HwL2aEyr6KAlktZqEA7F927OC8n65RXKumQWjxwWVROXeEmRY LbswPnnmc/UgrSQlzHaIm33APBhBm0beSdFjotc= X-Google-Smtp-Source: ABdhPJxcA8EIjKxiqpePemmTV6VYctGuA6PpQrxahQRzhjWYRzqRN3/dg8YJsXI6kjfFXKpxBrLjfeLzCnltdRFCj2I= X-Received: by 2002:a2e:9396:: with SMTP id g22mr1318787ljh.135.1594885899526; Thu, 16 Jul 2020 00:51:39 -0700 (PDT) MIME-Version: 1.0 References: <529e7a72-8bd7-b4f4-a987-0e88d37e47b5@telia.com> <44637D3E-5F0B-4AEF-A154-21C8FF20ED91@stitcher.io> <35A1BC6F-D147-4692-8A12-A13B5ABF78D5@stitcher.io> In-Reply-To: Date: Thu, 16 Jul 2020 09:51:23 +0200 Message-ID: To: Arnold Daniels Cc: PHP Internals Content-Type: multipart/alternative; boundary="0000000000007fa4fb05aa8a4f32" Subject: Re: [PHP-DEV] [RFC] Saner string to number comparisons From: nikita.ppv@gmail.com (Nikita Popov) --0000000000007fa4fb05aa8a4f32 Content-Type: text/plain; charset="UTF-8" On Wed, Jul 15, 2020 at 5:12 PM Arnold Daniels wrote: > Hi Nikita, > > One of the problems with numeric string comparisons is that it might > interpret a hexadecimal value as scientific notation > > $red = '990000'; > $purple = '9900e2'; > $red == $purple; // true > > I suggest only interpreting a number formatted with a sign ("1e+100") or > with decimals ("1.0e100") as scientific notation as part of this RFC. These > are the notations that languages use when casting a float to a string, > never "1e100" > > PHP "1.0E+100" > JavaScript "1e+100" > Python "1e+100" > Ruby "1.0e+100" > Java "1.0E100" > > Arnold > Hey Arnold, I don't want to include this change in this RFC (because the proposal does not otherwise touch string-to-string comparison at all), but I do think this is a very good idea. I was not aware of this particular variant of the issue (i.e., that it also occurs with prefixes other than "0e") and this seems like a pragmatic way to resolve that particular ambiguity. A question here would be whether to make this something specific to string-to-string comparisons, or make a general change to numeric string recognition (i.e., no longer treat "1e100" as a numeric string, only "1.0e100" or "1e+100".) Regards, Nikita --0000000000007fa4fb05aa8a4f32--