Mail Archives: djgpp/2001/02/28/22:48:14
I test Gnu Fortran compiler, g77 (g772952b : gcc-2.95.2) with a little program
C A program to calculate the nett pay of a British worker
REAL GROSS, SUPER, TAXABL, TAX, NETTPAY
C Read gross pay
PRINT *, 'Type gross pay before deductions :'
READ *, GROSS
C Superannuation is 6 % of gross pay
SUPER = 0.06 * GROSS
C Tax is 25 % of pay, excluding superannuation contributions
TAXABL = GROSS - SUPER
TAX = 0.25 * TAXABL
C Fixed weekly deductions of £14.40
NETTPAY = TAXABL - TAX - 14.4
C Print details
PRINT *, 'Gross pay : ', GROSS
PRINT *, 'Superannuation : ', SUPER
PRINT *, 'Tax : ', TAX
PRINT *, 'Insurance : ', 14.4
PRINT *, ' '
PRINT *, 'Nett pay : ', NETTPAY
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?
Or is there a bug in Fortran / C compiler precision.
Another thing, that bothers me is size of exe- code (about 150 KB and when pkzipped
about 50 KB). Is there any way or switch to pack/ optimise code?
P.S. Does Gnu Pascal compiler exist and is there any user online for a little
Thanks in advance!
Mailto:VJSuorsa AT Surfeu DOT Fi
- Raw text -