Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78285 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37796 invoked from network); 23 Oct 2014 23:53:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Oct 2014 23:53:22 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.208 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.208 imap2-3.ox.privateemail.com Received: from [192.64.116.208] ([192.64.116.208:42029] helo=imap2-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 39/72-24679-1F499445 for ; Thu, 23 Oct 2014 19:53:22 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 689328C007D; Thu, 23 Oct 2014 19:53:19 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap2.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap2.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 3IK2pKhLXlVQ; Thu, 23 Oct 2014 19:53:19 -0400 (EDT) Received: from oa-res-26-28.wireless.abdn.ac.uk (oa-res-26-28.wireless.abdn.ac.uk [137.50.26.28]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id C25CC8C007B; Thu, 23 Oct 2014 19:53:17 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) In-Reply-To: <54495C0F.9080404@mabe.berlin> Date: Fri, 24 Oct 2014 00:53:15 +0100 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: <66B7B28C-2651-4A71-AC2A-55D4C7BB3DDC@ajf.me> <544959B8.20207@mabe.berlin> <54495C0F.9080404@mabe.berlin> To: Marc Bennewitz X-Mailer: Apple Mail (2.1990.1) Subject: Re: [PHP-DEV] [RFC] Safe Casting Functions From: ajf@ajf.me (Andrea Faulds) > On 23 Oct 2014, at 20:50, Marc Bennewitz wrote: >=20 > You addresses data loss on convert float to int. > Do you also address data loss on int to float? >=20 > |to_float(||9223372036854774784) -> pass |as it results in > 9223372036854774784 > |to_float(|||9223372036854774785|) -> |fail as it results in > 9223372036854774784 Floats aren=92t expected to be precise, so I don=92t see why this = shouldn=92t pass. It=92s a loss of data, sure, but merely of precision, = which is expected here. The reason I have to_int fail is because float = overflow to int completely mangles your input. -- Andrea Faulds http://ajf.me/