My first thought would be the log function (log(1) = 0, and log(1e9) = 20.7232658369464). Otherwise, you have 1000 ranges of size n .. n + ( 999_999 ), so you could just divide by 1_000_000.
Hope that helps.
Update: 2015-02-09
Thanks to choroba for catching my error in linking to the log function documentation.
In reply to Re: Encoding function needed
by atcroft
in thread Encoding function needed
by baxy77bax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |