This 1000000000L is kinda hard to read.  Add a <code>
const unsigned long GIGA = 1000000000L;
</code> at the start of the function and use it in place of the literal; it'll be clearer for the reader.
It may be worth doing likewise for MEGA = 1000000L, for use below.