Mail Archives: djgpp/2001/03/01/03:56:14
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 -