Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71018 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62148 invoked from network); 6 Jan 2014 15:19:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jan 2014 15:19:59 -0000 Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 217.147.176.204 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.204 mail4.serversure.net Linux 2.6 Received: from [217.147.176.204] ([217.147.176.204:54434] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C7/D5-20906-E99CAC25 for ; Mon, 06 Jan 2014 10:19:59 -0500 Received: (qmail 21972 invoked by uid 89); 6 Jan 2014 15:19:54 -0000 Received: from unknown (HELO linux-dev4.lsces.org.uk) (lester@rainbowdigitalmedia.org.uk@81.138.11.136) by mail4.serversure.net with ESMTPA; 6 Jan 2014 15:19:54 -0000 Message-ID: <52CACA26.8080407@lsces.co.uk> Date: Mon, 06 Jan 2014 15:22:14 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0 SeaMonkey/2.22 MIME-Version: 1.0 To: "internals@lists.php.net >> PHP internals" References: <001801cf07e9$a07af1e0$e170d5a0$@tutteli.ch> <52C5B5E1.5050609@lerdorf.com> <003c01cf07ee$123e08e0$36ba1aa0$@tutteli.ch> <52C5BE84.1050904@ajf.me> <52CABAA2.8090805@lsces.co.uk> <001001cf0aea$dfab1530$9f013f90$@tutteli.ch> In-Reply-To: <001001cf0aea$dfab1530$9f013f90$@tutteli.ch> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] NAN and INF cast to int From: lester@lsces.co.uk (Lester Caine) Robert Stoll wrote: >>> I'm +1 to make div by zero return INF. >> >> This begs the question 'how' ... >> If we are processing to integer values they produce an integer result and there >> is no provision for a 'number' INF. This is the exact sort of request that >> prompted my recent article on 'what is a number' ... >> > > PHP behaves already different. 1/2 = 0.5 > So it would be perfectly valid to define 2/0 = INF > > Personally, I would prefer to keep false for a division with two integers (e.g. 1/0) but would change the result as > follows if a float is involved > 1.0/0 = INF > 1/0.0 = INF > 0.0/0 = NAN > 0/0.0 = NAN > pretty much as other language behave (right?). But that is not 'cast to int' ... http://phpsurgery.org/wiki/integer is my take on some of this, and if you follow the results on stackoverflow asking why there is not a NAN or INF value for numbers in other languages you will see that your list only works for 'float' ... but mapping everything to float is wrong? The real problem here is what 'container' is created when calculating int(x) / int(y) = ??? 27/3 can give a clean int(9), but 27/2 has a remainder and 27/0 can't produce an int() result? Some other container needs to be created? -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk