<p>For example, when I'm dividing two ints and want a float returned, I superstitiously write something like this:</p>

<pre><code>int a = 2, b = 3;
float c = (float)a / (float)b;
</code></pre>

<p>If I do not cast <code>a</code> and <code>b</code> to floats, it'll do integer division and return an int.</p>

<p>Similarly, if I want to multiply a signed 8-bit number with an unsigned 8-bit number, I will cast them to signed 16-bit numbers before multiplying for fear of overflow:</p>

<pre><code>u8 a = 255;
s8 b = -127;
s16 = (s16)a * (s16)b;
</code></pre>

<p>How exactly does the compiler behave in these situations when not casting at all or when only casting one of the variables? Do I really need to explicitly cast all of the variables, or just the one on the left, or the one on the right?</p>

Division of integers:  cast any one of the operands, no need to cast them both.  If both operands are integers the division operation is an integer division, otherwise it is a floating-point division.
As for the overflow question, there is no need to explicitly cast, as the compiler implicitly does that for you:
```
```
#include <iostream>
#include <limits>

using namespace std;
int main()
{
    signed int a = numeric_limits<signed int>::max();
    unsigned int b = a + 1; // implicit cast, no overflow here
    cout << a << ' ' <<  b << endl;
    return 0;
}
```
```