Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101443 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24096 invoked from network); 29 Dec 2017 17:18:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Dec 2017 17:18:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 212.232.25.164 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 212.232.25.164 mx208.easyname.com Received: from [212.232.25.164] ([212.232.25.164:48966] helo=mx208.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0B/1B-47595-AD8764A5 for ; Fri, 29 Dec 2017 12:18:18 -0500 Received: from cable-81-173-133-76.netcologne.de ([81.173.133.76] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1eUyIP-0001yg-Cc; Fri, 29 Dec 2017 17:18:15 +0000 Reply-To: internals@lists.php.net To: "lists@rhsoft.net" , internals@lists.php.net References: <72392123-d37b-26df-6886-218f48205f8a@fleshgrinder.com> <58A5ABDF-AA25-46D4-83E7-4DE72E3DFF5E@gmail.com> <757270790.33iDQ9MZ2V@vulcan> Message-ID: Date: Fri, 29 Dec 2017 18:18:05 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-DNSBL-PBLSPAMHAUS: YES Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Scalar Pseudo-type From: php@fleshgrinder.com (Fleshgrinder) On 12/29/2017 4:09 PM, lists@rhsoft.net wrote: > > Am 29.12.2017 um 13:08 schrieb Fleshgrinder: >> What is the use case for `int|float`? I mean, if f is able to process a >> `float` than f is able to process an `int` and since `int` is already >> automatically changed to a `float`, well, you're done > > just read the mass of bugreports caused by float answered with the > default paragraph below and you know why you don't want your int-values > silently converted to a float > > 7 may become to 7.000000000000000001 or something similar and "$x === 7" > may also fail wile the argument was int 7 > ________________________ > > Floating point values have a limited precision. Hence a value might > not have the same string representation after any processing. That also > includes writing a floating point value in your script and directly > printing it without any mathematical operations. > > If you would like to know more about "floats" and what IEEE > 754 is, read this: > http://www.floating-point-gui.de/ > Obviously but this does not answer anything. You expect an int or a float, hence, you need to be prepared to handle floats. Your 7 example is the best illustration. You need to handle those situations in your script with the appropriate strategy for your domain (rounding, truncation, floor, ...). -- Richard "Fleshgrinder" Fussenegger