18.08.2013 Views

Dalla A alla Z passando per C - Robotica

Dalla A alla Z passando per C - Robotica

Dalla A alla Z passando per C - Robotica

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Se uno dei due o<strong>per</strong>andi può essere un puntatore, in tal caso il risultato è un puntatore. Come<br />

<strong>per</strong> la moltiplicazione, non c’è nessun controllo sull’overflow.<br />

int a = 200, b = 300;<br />

unsigned int c;<br />

c = a - b; /* un numero positivo: 2 <strong>alla</strong> 32 meno 100 */<br />

6.21 Spostamento dei bit (shift)<br />

o<strong>per</strong>atore <br />

maggiore maggiore<br />

sintassi var >> n<br />

n. o<strong>per</strong>andi 2<br />

utilizzo effettua lo scorrimento a destra di n posizioni dei bit di var<br />

associativita’ =⇒<br />

commutativita’ NO<br />

Lo shift verso sinistra comporta l’inserimento sulla destra di tanti zeri quante sono le cifre<br />

spostate. Lo shift verso destra comporta l’inserimento sulla sinistra di tanti zeri quante sono le<br />

cifre spostate.<br />

Per esempio<br />

char c, c1;<br />

c = 0x0d; /* 00001101 */<br />

c1 = c

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!