Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:31915 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98561 invoked by uid 1010); 26 Aug 2007 08:41:29 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 98546 invoked from network); 26 Aug 2007 08:41:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Aug 2007 08:41:29 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.146.176 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.146.176 wa-out-1112.google.com Received: from [209.85.146.176] ([209.85.146.176:27804] helo=wa-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6E/32-16243-8BC31D64 for ; Sun, 26 Aug 2007 04:41:29 -0400 Received: by wa-out-1112.google.com with SMTP id m28so1462588wag for ; Sun, 26 Aug 2007 01:41:25 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ERkTfqCblmqxBKfNA8XEXzz6DmDYc9zL9YC/t9IbdQ029qvsQAa10JC2Q7FfGsusGHS+hYwEYCrHBddfDb2mdDhi2bb8ZnvltuS32pxu7vFO1482kIwNfMxnGghjJNEA+oaMEKTEBRo3NDTAtSZdpEvjM1V0hgAXzxTL850lghc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ZoMZ6fGDHULdFNs/eR+7CK80k/ysQwRn3KcPZfXwGHtJ0EnnJPg4DJEDmaF0bX76az6Ndemd5K0SwZGKQdW72OumNWAGUohaDaFjJ+OmlWhBn9HOhi7e+fAazJDigcYPo2N8mITWcIcgmPXp3QOe1kk1hkE4q4OD149qhEB8Vlw= Received: by 10.114.177.1 with SMTP id z1mr1207101wae.1188117682564; Sun, 26 Aug 2007 01:41:22 -0700 (PDT) Received: by 10.114.180.9 with HTTP; Sun, 26 Aug 2007 01:41:22 -0700 (PDT) Message-ID: Date: Sun, 26 Aug 2007 10:41:22 +0200 To: "Zoe Slattery" Cc: internals@lists.php.net In-Reply-To: <46CDA789.3080109@googlemail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <46CDA789.3080109@googlemail.com> Subject: Re: [PHP-DEV] Testing math functions From: pierre.php@gmail.com (Pierre) 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). --Pierre