Dalla A alla Z passando per C - Robotica
Dalla A alla Z passando per C - Robotica
Dalla A alla Z passando per C - Robotica
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
} else if (sizeof(int) == 8) {<br />
/* codice <strong>per</strong> 64 bit */<br />
} else {<br />
/* codice <strong>per</strong> processore a 32 bit */<br />
}<br />
6.18 Moltiplicazione e divisione<br />
o<strong>per</strong>atore ∗<br />
asterisco<br />
sintassi espr1 * espr2<br />
n. o<strong>per</strong>andi 2<br />
utilizzo moltiplica espr1 <strong>per</strong> espr2<br />
associativita’ =⇒<br />
commutativita’ SI<br />
L’asterisco in questo uso non provoca ambiguità con la dereferenziazione di puntatore, <strong>per</strong>ché<br />
la moltiplicazione ha due o<strong>per</strong>andi e comunque non può essere effettuata sui puntatori. La<br />
moltiplicazione intera non gestisce l’overflow dei valori.<br />
o<strong>per</strong>atore /<br />
slash<br />
sintassi espr1 / espr2<br />
n. o<strong>per</strong>andi 2<br />
utilizzo divide espr1 <strong>per</strong> espr2<br />
associativita’ =⇒<br />
commutativita’ NO<br />
La divisione intera scarta il resto.<br />
/* conversione di tem<strong>per</strong>atura */<br />
fahr = cels * 9 / 5;<br />
/* errato <strong>per</strong> <strong>per</strong>dita del resto: usare "* 5 / 9" */<br />
cels = fahr / 9 * 5;<br />
/* overflow se sec < -2 o sec > 2 */<br />
int nsec = sec * 1000000000<br />
63