Need 64-bit math here to avoid overflow.