Avoid 32-bit integer overflow.

Only cast down to an integer once the value has been divided by
MEGABYTES.