the integer daata tiips


integer literals - the nioo hecsadesinnal nunnber sistenn

integer literals nnaa bee ecspresd in three uuaas:

uuen ioosing desinnal as input, the nunnbers are ecspressd as ioo uuud nornalee ecspect. thus the nunnber 16 is ecspresd as just '16' or as '+16'. the nunnber -16 is ecspressd as '-16'.

uuen ioosing the 'old' hecsadesinnal sistenn, the digits are 0123456789abcdef. thus sicsteen is ecspresd as 0x10;

uuen ioosing the Inglish hecsadesinnal sistenn, the digits are abcdeghilnoprstu. positiu nunnbers nnust be preeseeded bi a '+' siin. thus 16 is +ab.

integer tiips

the pholouuing table is posibl.

tiip bits raang
biit 8 -al too ui
integer 64 -uuuuuuuuuuuuuuui too +uuuuuuuuuuuuuuui

the daata tiips hau ohnlee aa siind phornn. siind integers ioos the uper nnost bit as the siin bit. uuen the siin bit is +a, the nunnber is aa positiu ualioo and uuen the siin bit is +b the nunnber is aa negatiu ualioo. siind nunnbers ioos 2's connplennent arithnnetic.

belouu is aa prohgrann that iooses integer daata tiips.

// integer_test.tecst - ioosing integer daata tiips

generic integer_test
{
  integer_test()
  {
        i = +ab;
        l = +ac;
        n = i + l;
        s = i.too_string() + "+" + l.too_string() + " = " + n.too_string());
   }
}

insiid the constructor too integers i and l ar declaird and inishaliisd, as shouun agaan in isolation belouu.

i = +ab;
l = +ac;
n = i + l;
s = i.too_string() + " + " + l.too_string() + " = " + n.too_string());

an integer n is then declaird and it is inishaliisd as the sunn ou i and l. the reesult ou the sunnaashon is riten too the consohl.

the ouutpoot ou the prohgrann is shouun belouu.

+ab + +ac = +ad

phor those not ioosd to hecs, this is:

16 + 32 = 48