Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78280 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16647 invoked from network); 23 Oct 2014 19:50:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2014 19:50:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@mabe.berlin; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@mabe.berlin; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mabe.berlin from 80.237.132.167 cause and error) X-PHP-List-Original-Sender: php@mabe.berlin X-Host-Fingerprint: 80.237.132.167 wp160.webpack.hosteurope.de Received: from [80.237.132.167] ([80.237.132.167:34040] helo=wp160.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 48/5C-41150-51C59445 for ; Thu, 23 Oct 2014 15:50:45 -0400 Received: from dslb-178-005-231-204.178.005.pools.vodafone-ip.de ([178.5.231.204] helo=[192.168.178.30]); authenticated by wp160.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) id 1XhOPC-0004nr-9D; Thu, 23 Oct 2014 21:50:42 +0200 Message-ID: <54495C0F.9080404@mabe.berlin> Date: Thu, 23 Oct 2014 21:50:39 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: internals@lists.php.net References: <66B7B28C-2651-4A71-AC2A-55D4C7BB3DDC@ajf.me> <544959B8.20207@mabe.berlin> In-Reply-To: <544959B8.20207@mabe.berlin> Content-Type: multipart/alternative; boundary="------------060500020909060005050506" X-bounce-key: webpack.hosteurope.de;php@mabe.berlin;1414093845;9d56bbb7; Subject: Re: [PHP-DEV] [RFC] Safe Casting Functions From: php@mabe.berlin (Marc Bennewitz) --------------060500020909060005050506 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit You addresses data loss on convert float to int. Do you also address data loss on int to float? |to_float(||9223372036854774784) -> pass |as it results in 9223372036854774784 |to_float(|||9223372036854774785|) -> |fail as it results in 9223372036854774784 | Marc | On 23.10.2014 21:40, Marc Bennewitz wrote: > I really like the strictness of this casting rules except of "010" will > be a valid integer / float. > As of you don't allow "0x" and trailing white spaces as valid numbers > and don't allow floating like syntax as integers even if it result in > mathematical integer. > > Allowing prefixed "0" as valid numbers results in a small data loss > ("010" !== to_string(to_int("010"))), > is simple to address in user land with ltrim("010", "0") (Same argument > as trailing whitespace) > and collides with octal notation (010 !== to_int("010")) > > Marc > > On 21.10.2014 00:57, Andrea Faulds wrote: >> Good evening, >> >> I am presenting a new RFC to add a set of three functions to do validated casts for scalar types: >> >> https://wiki.php.net/rfc/safe_cast >> >> Please read it. >> >> Thanks! >> -- >> Andrea Faulds >> http://ajf.me/ >> >> >> >> >> > --------------060500020909060005050506--