delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/01/08:06:35

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Fortran / C compiler precision and code pack
Date: 1 Mar 2001 13:02:26 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 19
Message-ID: <97lh92$5g2$1@nets3.rz.RWTH-Aachen.DE>
References: <3a9e3c59 DOT 3439 DOT 0 AT surfeu DOT fi>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 983451746 5634 137.226.32.75 (1 Mar 2001 13:02:26 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 1 Mar 2001 13:02:26 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

>>If your problem is with 14.399996 being printed instead of 14.4,
>>that's normal: REAL variables only have about 6.5 digits of
>>precision.  Try using DOUBLE PRECISION instead.

> Thanks, it seems to be ok. 
> But was it a bug, I have newer seen before in my long life?

It was not so much a bug, but a an error in your expectation about the
program's behaviour. You'ld have to learn a bit more about Fortran to
see how to get the behaviour you expected. And a bit more about
numerical computation in general to see why doing this kind of stuff
with a datatype like REAL is a bad idea --- professional software of
this type would usually count pennies (or even fractions of pennies),
not pounds, and store everything in INTEGER or even INTEGER*8
variables.

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019