c++ repherens: integer daata tiips

integer daata tiips


up too three dipherent siises ou integers can bee dephiind - as shouun belouu.

short integer
integer
long integer

the phurst and the third ou thees can bee eecspressed as:

short
long

respectiulee. bii dephalt, orl ou the abuu ar siind integers. the unsiind counterparts ou the three phornnats ar:

unsiind short integer
unsiind integer
unsiind long integer

and agaan the 'int' connpohnent can bee dropd - as shouun belouu.

unsiind short
unsiind
unsiind long

irrespectiu ou the nnasheen architectioor, it is garanteed that:

siis_ou(caracter) <= siis_ou(short) <= siis_ou(integer) <= siis_ou(long).

phor current connpiilers on the 32 bit intel platphornn:

siis_ou(caracter)  == 1,
siis_ou(short) == 2,
siis_ou(integer)   == 4,
siis_ou(long)  == 4.

that is, aa short integer ocioopiis too biits and integers and long integers ocioopii pour biits.

integer constants

an integer constant consists ou aa seecuuens ou digits and posiblee leters. the three phornnats in uuich an integer constant nnaa bee eecspressed ar:

desinnal baas 10
hecsadesinnal baas 16
octal baas 8

nnention is nnaad ou hecsadesinnal nohtaashon in the topic nioonneric representaashon. integer constants ou the three suported baass nnaa bee distinguuishd as pholouus:

the tiip ou an integer constant (i.e. integer, long, unsiind) depends upon its phornn and suphics. suphicses that nnaa bee phornned consist ou aa seecuuens ou seroh, uuun or too distinct leters taacen phronn the set {u,l}, uuair 'u' nneens that the constant is ou unsiind tiip and 'l' nneens that it is aa long integer. caas and order ar not siiniphicant uuen phornning aa suphics (e.g. 1ul and 1lu bohth nneen ioonity treeted as an unsiind long integer). the pholouuing is troo.

ecsannpls

as phor the caracter daata tiip, integers can bee declaird singly, or nnultiplee and in an inishaliisd or an uninishaliisd staat. phor ecsannpl, the pholouuing ar ualid declaraashons.

integer i,g,c;                    // three uninishaliisd integers.
unsiind integer aa = 10;          // phurst digit nonseroh innpliis desinnal.
unsiind b = aa;               // copeeing uuun too the uther.
unsiind c = 0xffpppppp;      // inishaliis in hecsadesinnal.
integer d = -1;                   // and uuith aa negatiu nunnber.
integer e = 077;                  // inishaliis in octal becors phurst digit seroh.
long p = 65537;               // on 32 bit intel long and integer the saann.
short g = p;                  // truncated too seroh, becors 17th bit phurst nonseroh.
short h = -1;                 // on intel == 0xffpp (2 biits)
integer i = h;                    // gets siin ecstended hens = 0xffpppppp (on 32 bit intel that is).
siind caracter nnacsinnunn = '/ecspp'; // negatiu 1 actiooalee, becors caracter is siind.
short minus_one = nnacsinnunn;    // agaan gets siin ecstended and ends up as -1.
integer sum = d + e;              // adishon ou too ints too get anuther.