[comp.lang.modula2] CARDINAL and INTEGER number in Mod-2

schwab@canisius.UUCP (Ann Schwab) (09/08/89)

I have just started taking a class in modula-2 and on our first project I 
noticed a small quirk with CARDINAL and INTEGER numbers.  When you are reading 
in a number from the keyboard it seems to work on all types of numbers and 
characters.  In doing some further research I found that when a negative number
was put into a CARDINAL field then it would return a 0 and the program would 
still keep going.  When a decimal number such as 9.87 or a series of characters
were entered then it would return a number between 2014 and 2020 and again it
kept on running.  I was trying my hardest to crash my program with invalid
input and I couldn't do it no matter how hard I tried.  Does anyone out there 
know why this was happening and how you can check to make sure that the number 
inputted is really a CARDINAL or INTEGER number and then have an error message 
register??
This same problem happened to the whole class and no one  knows why.    

Thanks in advance for any help that you can give.

Ann Schwab
in%"schwab@klaatu.canisius.edu"

MARKV@UKANVAX.BITNET ("MARK GOODERUM - UNIV. OF KANSAS ACS - MARKV@UKANVAX") (09/08/89)

What version of Modula-2 are you using!!!??? These symptoms sound suspiciously
like the Compiler is freely plugging the floating point into the CARDINAL
or some such rubbish.

-Mark Gooderum
 MARKV@UKANVAX

P.S.  Both of these conditions should cause a run time error, or at least
        a retry if your ReadCard was written robustly.