From owner-freebsd-questions Fri Jan 9 07:37:14 1998 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id HAA10332 for questions-outgoing; Fri, 9 Jan 1998 07:37:14 -0800 (PST) (envelope-from owner-freebsd-questions) Received: from mrelay.jrc.it (mrelay.jrc.it [139.191.1.65]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id HAA10317 for ; Fri, 9 Jan 1998 07:37:05 -0800 (PST) (envelope-from Dirk.vanGulik@jrc.it) Received: from elec.isei.jrc.it (elec.jrc.it) by mrelay.jrc.it (4.1/EB-950131-C) id AA13612; Fri, 9 Jan 98 16:38:28 +0100 Received: from elect6.jrc.it by elec.isei.jrc.it (4.1/EI-3.0m) id AA12029; Fri, 9 Jan 98 16:36:23 +0100 Posted-Date: Fri, 9 Jan 1998 16:35:34 +0100 (MET) Date: Fri, 9 Jan 1998 16:35:34 +0100 (MET) From: Dirk-Willem van Gulik X-Sender: dirkx@elect6.jrc.it Reply-To: Dirk-Willem van Gulik To: Yingjun He Cc: questions@FreeBSD.ORG Subject: Re: your mail In-Reply-To: <3.0.1.32.19980109091508.00969330@newton.ccs.tuns.ca> Message-Id: Reply-Path: Dirk.vanGulik@jrc.it Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Fri, 9 Jan 1998, Yingjun He wrote: > I am running FreeBSD2.25 and 2.05 and I found that the numerical calculation > results of the same program is different. Is this caused by the difference of > the operating systems? Or something wrong with my hardware? Most propably not; it is not uncommon for numerical calculation to be somewhat unstable. After many iterations a very small difference, well below the accuracy margnin propagates through. Check out for example 'Numerical Reciepes' for a good discussion. As an example consider the output of the programme below; a small conceptual thing, the order of the loop, not the formula, causes an increduble difference. Such a difference can by caused by compiler optimizations and couldless other small things. D1=1235325026304.000000 D2=1235334987776.000000 Dw. int main( int a, char * * b) { float d; int i; #define M 10000000 printf("start\n"); d=1234567890123.0; for( i=1; i 0; i--) d += 1.0*i/(1+i*i); printf("D2=%f\n",d); exit(0); }