Unsigned types

  •  int i1;          // range -2,147,483,684 to 2,147,483,684 
     signed int i2;   // range -2,147,483,684 to 2,147,483,684 
     unsigned int i2; // range 0 to 4,294,967,296 

Java does not know unsigned types, just like ADA. In a mixed language environment (e.g. C operating system, ADA applications) this can cause trouble. Also watch out for sign extension when you shift a variable to the right (division). A signed variable will introduce new "1" bits in the most significant position when it is shifted to the right.

Example 2. Shifting signed types

signed char foo = 0xFF;     // 11111111
                        signed char bar = foo >> 4; // 11111111
unsigned char foo = 0xFF;     // 11111111
                        unsigned char bar = foo >> 4; // 00001111