Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105783 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 77738 invoked from network); 23 May 2019 23:24:23 -0000 Received: from unknown (HELO thephantoms.co.uk) (176.126.243.54) by pb1.pair.com with SMTP; 23 May 2019 23:24:23 -0000 Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=exussum.co.uk; s=default; x=1559248341; h=Comment: DomainKey-Signature:Received:To:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To: References:Message-ID:User-Agent; bh=fwrbP9xzsdZe9VClih2PWornqaZ HiNGUjHHBFq/aMSk=; b=jZkW1JgbaA0XpRuThOXPiZ8SD3hkNYxcmEXFJGr2tPm 2KYO9CUDf2OKRYoqQxBi87Ip6isJ1rApuhBqU8NlopX5QrldQbfnTyQSzMbAa3wA BQIXiBTSvDCngcng/dn/TabOYPabh5k53OCa65rXPeOkr4uBFmZqKWTQzc3PhBGQ = Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=exussum.co.uk; h=Received:To:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:References:Message-ID:X-Sender:User-Agent; b=fhQYrs0d0N9JzjgdMjX32o6FhbL+VyR2JQ6Qtgs12YwKkgmHjnDTvWKCzZiAdH 85To+96X61IzvhfDs/SZkXeofI2hD67p2N1n1b7AEXcYq1BLYorY06+QCBwtUyCE KDtj/+2IaUEiRcuyjMU3/FLtgqWsJqXcaYo9G4mZsQyvI=; Received: (qmail 27941 invoked by uid 48); 23 May 2019 20:32:21 -0000 To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 23 May 2019 21:32:21 +0100 In-Reply-To: References: <4bdc84d133912367ab9d5139f37f9a6e@exussum.co.uk> Message-ID: X-Sender: scott@exussum.co.uk User-Agent: RoundCube Webmail/0.1 Subject: Re: [PHP-DEV] [RFC] Base convert changes From: scott@exussum.co.uk (Scott Dutton) Hi Nikita, Derick Thanks for your time looking at this. Not sure if this will sway you either way, Other programming languages do handle negatives correctly, for example (i can add this to the RFC if that helps) Javascript - https://jsfiddle.net/c16b4usp/ Python - https://repl.it/repls/OliveBlushingModem Go - https://play.golang.org/p/aLWg15c00Fy Its interesting that Javascript handles the large value example correctly, the other two error. There is likely a way to handle negatives in a way which also handles the large numbers though I'm not sure what that would be, I am happy to take any suggestions or look further into the engine to see how this could be done. I was planning on two votes, one for the invalid char changes and one for the negative changes. Either way the documentation should be changes to make it clear that either negative numbers or extremely large values will not return the expected value (unless there is a way to avoid both of these?) Happy to make any changes to the implementation as I said in the PR, my C is quite rusty Thanks Scott On 23.05.2019 17:32, Derick Rethans wrote: > On Thu, 23 May 2019, Nikita Popov wrote: > >> On Sat, May 18, 2019 at 11:22 AM Scott Dutton >> wrote: >> >> > 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 >> >> 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" > > I concur with Nikita here. I don't think you should change the sign > handling. I think this is something that actually use in real life > projects. > > cheers, > Derick > > -- > https://derickrethans.nl | https://xdebug.org | https://dram.io > Like Xdebug? Consider a donation: https://xdebug.org/donate.php, > or become my Patron: https://www.patreon.com/derickr > twitter: @derickr and @xdebug