Why can't I use int to calculate bytes to gigabytes?
<p>I ran into some trouble when converting bytes to gigabytes in my current project. Initially I did this:</p>

<pre><code> long requiredDiskSpace = 5000000000000; // In bytes
 int gb = (int)requiredDiskSpace / 1024 / 1024 / 1024;
</code></pre>

<p>This calculation becomes 0. (Correct should be 4 656). Then I switched to the <code>decimal</code> type, like this:</p>

<pre><code> long requiredDiskSpace = 5000000000000; // In bytes
 decimal gb = requiredDiskSpace / 1024 / 1024 / 1024;
 int gbAsInt = (int)gb;
</code></pre>

<p>This calculation (correctly) makes <code>gbAsInt</code> 4 656.</p>

<p>Now, my question is simply; why? To me, the calculations look similar, as I'm not interested in any decimal numbers I don't understand why I can't just use int in the actual calculation.</p>
