News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Conversion Error

Started by Ev!LC0N, October 13, 2006, 02:38:55 AM

Previous topic - Next topic

Ev!LC0N

Greetings-

Code below is to display a static variable that was initialized and a second variable that gets the user input.
Here is what I don't understand. When I input negative integers [ -128, -100 etc ] the code displays the negative integers.  When I enter a number >= 0, it displays the positive integers.  But when I enter a number such as +127, +100,  I get HLA Exception (5), Conversion Error.  Why does this happen?  From what I read from AoA, int8 represents a signed integer.  Why then, when I input numbers with + sign, I get a Conversion Error?

Cheers


static

            initvar:         int8   :=   -128;
            notinitvar:         int8;

begin DemoVars;

   // Display variable 'initvar' which is initialized:
   
   stdout.put   (
            
                  " The variable That Was Initialized is   initvar       ", initvar, nl
                  
            );
            
   stdout.put (
   
                  " Please Enter A Signed Integer                     ", nl
                  
            );
            
   stdin.get   (
   
                  notinitvar
                  
            );
            
   stdout.put   (   
      
                  " The Number That You Have Entered Is               ", notinitvar, nl
   
            );
   
   
end DemoVars;

Sevag.K

Enter possitive numbers without the '+' sign.  The library code doesn't look for '+', it only looks for '-' in front of numbers