Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!julius.cs.uiuc.edu!apple!agate!shelby!rutgers!cbmvax!ken From: ken@cbmvax.commodore.com (Ken Farinsky - CATS) Newsgroups: comp.sys.amiga Subject: Re: Lattice C double Message-ID: <14905@cbmvax.commodore.com> Date: 5 Oct 90 14:02:58 GMT References: <1990Sep28.063045.2599@ericsson.se> <14795@cbmvax.commodore.com> <1990Oct4.063507.1899@ericsson.se> Reply-To: ken@cbmvax.commodore.com (Ken Farinsky - CATS) Organization: Commodore, West Chester, PA Lines: 32 In article <1990Oct4.063507.1899@ericsson.se> etxpnil@etxsj23.ericsson.se writes: >In article <14795@cbmvax.commodore.com> ken@cbmvax.commodore.com writes: >>In article <1990Sep28.063045.2599@ericsson.se> etxpnil@etxsj23.ericsson.se writes: >>>main() >>>{ >>> double dub; >>> dub = 12345678.0; >>> dub = dub * 10.0; >>> printf("%.9g\n",dub); >>>} >>>When compiled with the Lattice C V5.04, I've got the following output: >>>123456779.999999999 >> >>Are you using the correct compiler flags and linker options... > >I've now tried it...with the same result... Ok, how about: printf("%.9lg\n",dub); /* value is a long float (double) */ Nope, that doesn't do it. Looks like the problem is that you are displaying more than 15 digits, which is beyond the accuracy of the numeric format that you are using. If you use a smaller number (1234.0), then you get the result that you expect. Are the other machines that you are using this on using a different numeric format? -- -- Ken Farinsky - CATS - (215) 431-9421 - Commodore Business Machines uucp: ken@cbmvax.commodore.com or ...{uunet,rutgers}!cbmvax!ken bix: kfarinsky