Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37425 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34987 invoked from network); 3 May 2008 17:21:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 May 2008 17:21:28 -0000 Authentication-Results: pb1.pair.com smtp.mail=truth@proposaltech.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=truth@proposaltech.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain proposaltech.com from 66.51.199.86 cause and error) X-PHP-List-Original-Sender: truth@proposaltech.com X-Host-Fingerprint: 66.51.199.86 exvs01.ex.dslextreme.net Windows 2000 SP4, XP SP1 Received: from [66.51.199.86] ([66.51.199.86:39800] helo=EXVS01.ex.dslextreme.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6D/14-10564-51F9C184 for ; Sat, 03 May 2008 13:21:28 -0400 Received: from 69.236.135.99 ([69.236.135.99]) by EXVS01.ex.dslextreme.net ([192.168.7.220]) via Exchange Front-End Server owa.dslextreme.net ([192.168.7.126]) with Microsoft Exchange Server HTTP-DAV ; Sat, 3 May 2008 17:24:02 +0000 Received: from inspiron by owa.dslextreme.net; 03 May 2008 10:21:21 -0700 To: internals@lists.php.net In-Reply-To: <481BE16C.6040103@suse.de> References: <001401c8ac74$dda6d060$98f47120$@com> <1209749793.1075.54.camel@inspiron.local> <481B5F45.4030106@gmail.com> <481B6068.9060402@lerdorf.com> <1209758625.1075.87.camel@inspiron.local> <481BE16C.6040103@suse.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: Sat, 03 May 2008 10:21:20 -0700 Message-ID: <1209835281.1075.140.camel@inspiron.local> Mime-Version: 1.0 X-Mailer: Evolution 2.8.2 Subject: Re: [PHP-DEV] Float comparison From: truth@proposaltech.com (Todd Ruth) On Fri, 2008-05-02 at 23:52 -0400, Cristian Rodr=EDguez wrote: > Todd Ruth escribi=F3: >=20 > > Most people don't care about floating numbers beyond a certain=20 > > number of digits. =20 >=20 > That's the main flaw in your suggestion, "most people".. the language=20 > should be correct, do the real right thing. Would you suggest that the "real right thing" is to print 100 digits by default? That argument could be made, but I think everyone agrees that as a practical matter, most people don't care about most of the digits so a default is set for "precision" that makes most people happy without ever even knowing the "precision" setting exists. Why should things be any different for other non-progressing uses of a float? (By non-progressing, I mean a use of a float that doesn't affect digits of another float, such as doing a comparison or using a float as an array key.) A comparison_precision value could be set to 14 by default. That will make most people happy for most cases without ever even thinking about it. If someone wants more digits, they care enough about floats to likely be aware of such settings. (and if they don't they need to be aware of all these issues and the improvements I'm encouraging wouldn't help them - not being able to help that small percent isn't a reason not to help the others) There seems to be an attitude of "that's what you get for using floats". In c, you can't compare strings intuitively because you'd be comparing addresses not strings. php hides that ugly bit of internals, so the programmer can compare two strings without worrying about all that. No one says "That's what you get for using strings; you always need to make a function call to compare strings." Why not let the programmer get intuitive behavior for floats too? The people who want to have incredibly small epsilons know their stuff and would use a vary large value for comparison_precision (and if they don't know their stuff need to learn it any case). - Todd