Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo Pascal - <b> integer whole numbers pp 41</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 INTEGER                        Whole Numbers                          pp 41


 Define:  Whole numbers in the range of -32768 to +32767.

 Purpose: Fast and efficient whole number math.

 Notes:   Integers occupy two bytes in memory.

          Overflow of integer arithmetic operations is not detected.
          Partial results in integer calculations must be kept within the
          integer range.

          1000 * 100 / 50 will not yield 2000, as the partial result
          of the multiplication will cause an overflow.

 Bugs:    -32768 is a valid negative integer, but the compiler will
          flag it as Error 56, Invalid Integer Constant.  Use the
          equivalent hex value $8000 to bypass this bug.

 Usage:
       CONST
          BugVar :  Integer = -32768;  { Value = $8000  -  Gives Error 56   }
          OKVar  :  Integer =  $8000;  { Value = -32768 -  No compile error }

       VAR
          IntVar :  Integer;           { Declare an integer variable        }

       BEGIN
          IntVar := -32768 ;           { Legal value causes Error 56        }
          IntVar :=  $8000 ;           { Legal value does not give error    }
       END.

See Also: Real

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson