How to scale a random integer in $[A,B]$ and produce a random integer in $[C,D]$ I know there are many methods to scale a number from range $[A,B]$ to a range $[C,D]$, and I've searched over and over the web. I've seen this math.SE thread.
I need to scale a big number (signed 32-bit integer) between $-2147483648$ and $2147483647$, to a smaller range (from 0 to millions).
However, the original number is generated by a random number generator that I cannot control in any way, so I must to be sure that the output formula does not alter its randomness (in a way that I can demonstrate - academic papers are well accepted).
I need the correct way to scale this number taking in consideration that:


*

*the output range must have as maximum value a power of two (e.g., $4194304$)

*the formula can be demonstrated

*the formula does not alter the randomness of the source number


Anyone may be of help?

This works in special cases:
Let $[a,b]$ be an interval and consider a uniform distribution on the intervals in this interval.  Let $k$ be the number of integers in $[a,b]$.
Let $[c,d]$ be another interval and suppose that the number of integers in this interval is $l$.
BIG ASSUMPTION: Suppose that $l\mid k$.
Then, any $\frac{k}{l}=m$ to $1$ map will give you a uniform distribution on $[c,d]$.
For example, if you have the number $n$, you could take $n\pmod l$ and then add $c$.
If you don't have the BIG ASSUMPTION, then you may be able to weight the map described here, (and not have it exactly $m$ to $1$, but that is more challenging and situation specific).
