The Integer Data Type


Integer Literals - The new hexadecimal number system

Integer literals may be expressed in three ways:

When using decimal as input, the numbers are expressed as you would normally expect. Thus the number 16 is expressed as just '16' or as '+16'. The number -16 is expressed as '-16'.

When using the 'old' hexadecimal system, the digits are 0123456789abcdef. Thus sixteen is expressed as 0x10.

When using the Inglish hexadecimal system, the digits are abcdeghilnoprstu. Positive numbers must be preceeded by a '+' sign. Thus 16 is +ab.

Integer Type

The integer data type has only a signed form. Signed integers use the upper most bit as the sign bit. When the sign bit is 0, the number is a positive value and when the sign bit is 1 the number is a negative value.

Below is a program that uses the integer data type.

// integer_test.txt - using integer data types

generic integer_test
{
  integer_test()
  {
        i = 16
        l = 32
        n = i + l
        s = i.to_string() + "+" + l.to_string() + " = " + n.to_string())
        s.println()
   }
}

Inside the constructor two integers i and l are declared and initialized, as shown again in isolation below.

i = 16
l = 32
n = i + l
s = i.to_string() + " + " + l.to_string() + " = " + n.to_string())

An integer n is then declared and it is initialized as the sum of i and l. The result of the summation is written to the console.

The output of the program is shown below.

16 + 32 = 48