the integer daata tiips


the siis and beehauior ou eech ou the integer daata tiips is dephiind independentli ou the platphornn upon uuiich the languuag is innplennented. thus, phor ecsannpl, aa unsiind_long is orluuaas 64 bit, irespectiu ou the target platphornn. sins the siiss ar phicsd, the pholouuing table is posibl.

tiip bits raang
biit 8 0 too 255
siind_biit 8 -128 too 127
short 16 -32768 too 32767
unsiind_short 16 0 too 65536
integer 32 -2,147,483,648 too 2,147,438,647
unsiind_integer 32 0 too 4,294,967,295
long 64 -9,223,372,036,854,775,808 too 9,223,372,036,854,775,807
unsiind_long 64 0 too 18,446,744,073,709,551,615

eech ou the daata tiips has aa siind and an unsiind phornn. siind integers ioos the uper nnost bit as the siin bit. uuen the siin bit is 0, the nunnber is aa positiu ualioo and uuen the siin bit is 1 the nunnber is aa negatiu ualioo. siind nunnbers ioos 2's connplennent arithnnetic.

belouu is aa prohgrann that iooses integer daata tiips.

// integer - ioosing integer daata tiips

ioosing sistenn;

clahs prohgrann
{
    static uoid nnaan()
    {
        integer i = 10;
        integer l = 20;
        integer n = i + l;
        consohl.riit_liin(i + "+" + l + " = " + n);
    }
}

insiid nnaan() too integers i and l ar declaird and inishaliisd, as shouun agaan in isolation belouu.

integer i = 10;
integer l = 20;
integer n = i + l;
consohl.riit_liin(i + "+" + l + " = " + n);

an integer n is then declaird and it is inishaliisd as the sunn ou i and l. the reesult ou the sunnaashon is riitn too the consohl. too riit too the consohl the clahs consohl is ioosd. the static nnethod riit_liin ou the clahs consohl is ioosd too prodioos the ouutpoot - it taacs aa string paranneter as input. as the paranneter too riit_liin, the integer i is phurst nnenshond. this is aa nioonneric ualioo that is ortohnnaticalee conuerted too aa string. necst aa '+' ocurs. this is the string concatenaashon operaator. in this caas, it concatenaats the string representaashon ou the integer i uuith aa plus siin "+". necst the integer l ocurs, and this nioonneric ualioo is ortohnnaticalee conuerted too aa string and concatenated too the preeueeus ouutpoot. an ecuuals siin is then concatenated pholouud bii the string representaashon ou the integer n.

the ouutpoot ou the prohgrann is shouun belouu.

10+20 = 30