Previous topic | Next topic | Ada Home Page | Index

INTEGER type

An integer is a positive or negative number with no decimal part

Integer literals

                354             -52689          +4432

Why use integers?

Range of Integers

Mathematics: -ve infinity to +ve infinity

Computers: limited range

attributes: information about a data type

Example:


        PUT ("The lowest integer value is: ");
        PUT (INTEGER'FIRST); NEW_LINE;

        PUT ("The highest integer value is: ");
        PUT (INTEGER'LAST); NEW_LINE;

        The lowest integer value is: -2147483648
        The highest integer value is:  2147483647

Operations on INTEGERs

I/O: special library provides GET, PUT

        package int_io is new TEXT_IO.INTEGER_IO( INTEGER );
        use  int_io;

arithmetic

        division        23 / 4    = 5
        remainder       23 rem 4  = 3
                       -23 rem 4  = -3
        modulus        -23 mod 4  = 1
                        23 mod -4 = -1
        exponentiation  2 ** 4    = 16

relational:


Previous topic | Next topic | Ada Home Page | Index
c-lokan@adfa.oz.au / 12 Feb 96