Abstract

The INTEGER(1) type should be used for large arrays when memory is at a premium for variables which will have only positive, negative, and zero whole number values within the range of -129 to 127..

Form

integer-1-type
INTEGER(1) | INTEGER(Kind=1) | INTEGER*1

Semantics

integer-1-type
  1. The integer-1-type is stored in 1 byte of memory, almost always (if not always) as a twos complement binary number.
  2. The language specification does not specify an encoding, but most current computers use 2's complement encoding for integer-1 integers:
             
    765 43210
    S 2's Complement Magnitude
    The leftmost bit is the sign bit (1 for negative numbers, 0 for positive numbers and zero), and the other 7 bits are the magnitude.  For non-negative numbers, the magnitude is directly in natural binary.  For negative numbers, the magnitude is the 2's complement of the encoded representation.
  3. An 8 bit 2's complement number has a range of -27 to (27 -1), or - 128 to 127.

Remarks

Example

!  File     Integer1.f95
!  Language Fortran 95
     
PROGRAM Integer1
  Integer(1) I
  Integer J
  Integer(Kind=1) K
  Integer*1 L
  I = 1
  J = I + 10
  K = J - 100
  L = J * K             ! This will overflow & be truncated
  Print *, 'I = ', I
  Print *, 'J = ', J
  Print *, 'K = ', K
  Print *, 'L = ', L
END PROGRAM Integer1
      

Output


    

Other Languages

C Now C char Type intrinsic type
C++ Now C++ char Type intrinsic type
FORTRAN Now
FORTRAN INTEGER(2) Type intrinsic type
Java Now Java byte Type intrinsic type