delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/01/03:56:14

Date: Thu, 1 Mar 2001 10:54:14 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: "Mr. Veli Suorsa" <VJSuorsa AT Surfeu DOT Fi>
cc: Djgpp AT delorie DOT com
Subject: Re: Fortran / C compiler precision and code pack
In-Reply-To: <3a9dc591.6468.0@surfeu.fi>
Message-ID: <Pine.SUN.3.91.1010301105206.4534N-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Thu, 1 Mar 2001, Mr. Veli Suorsa wrote:


>       PRINT *, 'Gross pay      : ', GROSS
>       PRINT *, 'Superannuation : ', SUPER
>       PRINT *, 'Tax            : ', TAX
>       PRINT *, 'Insurance      : ', 14.4
>       PRINT *, ' '
>       PRINT *, 'Nett pay       : ', NETTPAY
>       STOP
>       END
> ---
> 
> Compiler seems to work correctly, but...
> 
> When you give 1600 
> to gross pay, print is:
> 
>  Gross pay      : 1600
>  Superannuation : 96.
>  Tax            : 376.
>  Insurance      : 14.3999996
>  
>  Nett pay       : 1113.59998
> 
> Did I everything right, because insurance (real) was different from 14.4?

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.

> P.S. Does Gnu Pascal compiler exist and is there any user online for a little
> sort test?

There's a GNU Pascal compiler on the usual DJGPP sites; look for 
v2gnu/gpc20bb.zip.

- Raw text -


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