Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105779 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 27318 invoked from network); 23 May 2019 15:28:45 -0000 Received: from unknown (HELO mail-lj1-f177.google.com) (209.85.208.177) by pb1.pair.com with SMTP; 23 May 2019 15:28:45 -0000 Received: by mail-lj1-f177.google.com with SMTP id h19so5303813ljj.4 for ; Thu, 23 May 2019 05:36:38 -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=782l01hb9+IeWIGJUSRbB5cAdImBpX33sVGTlMRX+h0=; b=k0nCgHXbAqprbrnH4VOHD7j7g611syQal0aQ/51uGK2C57/03EmOzXu/ig6DNLwOog r8lnzVYG6Y7AlgldlheRRBjMgkFN4f5iL97qw0NF5yomfrVHADEI31IkoIsOGkQdkR2Y aWy1DCdwumDHe2zqxTTd5nB1QgvQcRu458W0Eaf9bbzvtYBqwnvzfPAscx5uiFDBMd8L K9DPZTrxLiZWPwoSoFfLrYnQwyJLV1XpLfAUHQodO23q66AJM3ctQBJl3yKl/TLo6uI2 eBwfC9Ph9xegypGJws3gYTDtEF6t3lOmMKHwsPhe6pAYr0oh2wsNfZZZqRClwKISP6BC 8S2g== 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=782l01hb9+IeWIGJUSRbB5cAdImBpX33sVGTlMRX+h0=; b=MB/wqShAS0p+ByyC0jvdhmaAQ84bbLSaXpAR39gGk1xrvUzYzh8oQqrTxQYdM39MPO E+P10/NmGXny6TDU7GZaEEIEUqkmjfbvX1d6P3x6dS5tM8wb+tOk/AOxy+JUsSn+mss2 8Jzw/Ige3+jh3XWXuxO8b4h6K52fQ7Pj6+f4BujZ5KOna9wbO1+cAEJjtCPNuQE19AVx USVkd8oTJJVQB+VXVhDvpy1m1BMyam8POzsG4nKjG4aiO+iOwYfjXSOoRywFhMgw0HAO mkJfJrLLdYuX/o/ofc8K6XQxTXStUjpd6J/JMIY0NvgxZIr3aPfFAwj+I1ngdeNv8uKH Zo/w== X-Gm-Message-State: APjAAAW7MHZtkGdJM51GRkR6Y31wVjXz7S+ORbexqI3daRZM90XfvQ+O vX7R9drb1nzT7MinfNq8G5xAw8xtG+TlqAhm6j9Gax7+Jws= X-Google-Smtp-Source: APXvYqz4f/pPfI41AQTqflLwNzwbqb/gm9yisDn1bfNHGt0DEpT7M+Nz38H3oroS/zpRHOQg4651117i3ocheQqXZjQ= X-Received: by 2002:a2e:730c:: with SMTP id o12mr47210412ljc.61.1558614997848; Thu, 23 May 2019 05:36:37 -0700 (PDT) MIME-Version: 1.0 References: <4bdc84d133912367ab9d5139f37f9a6e@exussum.co.uk> In-Reply-To: <4bdc84d133912367ab9d5139f37f9a6e@exussum.co.uk> Date: Thu, 23 May 2019 14:36:21 +0200 Message-ID: To: Scott Dutton Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000049d4ab05898d55f0" Subject: Re: [PHP-DEV] [RFC] Base convert changes From: nikita.ppv@gmail.com (Nikita Popov) --00000000000049d4ab05898d55f0 Content-Type: text/plain; charset="UTF-8" On Sat, May 18, 2019 at 11:22 AM Scott Dutton wrote: > Hi all > > I have made some changes to base_convert which I feel would be more > consistent with the current PHP (warning when there are errors, and not > just returning the best value it can) > > The RFC has some examples of what will change. > > Currently the code works but a lot of tests fail due to extreme range's > (also mentioned in the RFC) > > If this passes I will fix the effected tests and add some more covering > the new behavior. > > https://wiki.php.net/rfc/base_convert_improvements > > Let me know your thoughts > > Thanks > > Scott > Hi Scott, I definitely agree with the part of the RFC that warns on garbage characters in the string. I'm not so sure about the changes in sign handling. The problem I see is that certain bases (in particular hex) are pretty much never used with an explicit sign, instead they are understood to be in two's complement representation. For example, code like this will currently work: var_dump(dechex(0xffffffff00000000)); // string(16) "ffffffff00000000" While after your change it will result in "-100000000", which for hex numbers is rather unexpected. (This example is somewhat non-great because there is a loss of accuracy for 64bit numbers represented as doubles -- the same examples with 32-bit integers on 32-bit systems would be fully reliable.) Nikita --00000000000049d4ab05898d55f0--