Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:31965 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29488 invoked by uid 1010); 29 Aug 2007 15:20:55 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 29473 invoked from network); 29 Aug 2007 15:20:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Aug 2007 15:20:55 -0000 Authentication-Results: pb1.pair.com header.from=zoe.slattery@googlemail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=zoe.slattery@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 64.233.182.188 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: zoe.slattery@googlemail.com X-Host-Fingerprint: 64.233.182.188 nf-out-0910.google.com Received: from [64.233.182.188] ([64.233.182.188:50138] helo=nf-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D1/42-17634-7DE85D64 for ; Wed, 29 Aug 2007 11:20:55 -0400 Received: by nf-out-0910.google.com with SMTP id e27so202432nfd for ; Wed, 29 Aug 2007 08:20:52 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=googlemail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=jDXjiMl2h/Ez8ot0aSVdDc6OzbEhBsCUNOOrxMOlokWrVX6ajuBYbDiUyeg/zI2ucn/67s6FeI4PS6GhhCTGOtXW2Y6J9+09AqDjD4AmOQNdA6odojkDmSUa5+Z+TymP+rIf1YK/UDBacEvTmVSlIKjLqdmOJ0i541Wpggyg76o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=kvf22zuHv9n+AKqpQ6a6d1buBpaMiUEMv4LRaCPNmk4BX9Jfeo2gJdaHc4qdV8/R/olRRfb/fYLKzla08nXeBVLnOjFb8PnfJGAe6D2A5eo4DB975CTdqoFXTQ9MfnP02ma4bXBFjAmkg8pPqYj3Wx65aro0tE7x78KxN4PGK4Y= Received: by 10.82.177.3 with SMTP id z3mr1540804bue.1188400851629; Wed, 29 Aug 2007 08:20:51 -0700 (PDT) Received: from ?9.20.187.127? ( [195.212.29.92]) by mx.google.com with ESMTPS id s7sm9225486uge.2007.08.29.08.20.48 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 29 Aug 2007 08:20:49 -0700 (PDT) Message-ID: <46D58ECF.1070104@googlemail.com> Date: Wed, 29 Aug 2007 16:20:47 +0100 User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Pierre CC: internals@lists.php.net References: <46CDA789.3080109@googlemail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Testing math functions From: zoe.slattery@googlemail.com (Zoe Slattery) Pierre wrote: > On 8/23/07, Zoe Slattery wrote: > >> Hi - I've writing a few tests for the math extension and have a question >> about floating point precision. >> >> Here's a small example: >> >> --TEST-- >> Test return type and value for expected input sin() >> --INI-- >> precision = 14 >> --FILE-- >> > >> $threesixty = pi() * 2.0; >> echo "sin 360 = "; >> var_dump(sin($threesixty)); >> >> ?> >> --EXPECT-- >> sin 360 = float(-2.4492127076448E-16) >> >> Is it right to test for an exact number in this way? I was slightly >> suprised that I got the same number from Windows and Linux (maybe I >> shouldn't be). >> >> If not, I could write the test above to check that sin 360 is zero >> plus/minus some small number - but how small? >> > > It really depends on the architecture. Using a precision of 10 should > put you on the safe side, at least for the common architecture (intel, > amd and ppc). > Yes - you are right thanks. I'm currently testing that the answer is within +/- 1.0E-10 of what I expect - that works on the processor architectures that I have access to. I guess I'll find out what happens on the others wheh I check the test cases in :-). > --Pierre > >