I'm struggling with this for quite some time now. I'm trying to recalculate values uniformly distributed in real numbers range to numbers in non-negative range. Length of non-negative range can vary (but always is a power of two), and with increasing the length, amount of numbers increases up to length of second range, and step decreases.
The fixed real range is (-16,16). The non-negative range is <0,32). Amount of numbers is 32. Step is equal 0.5.
Now we want to recalculate numbers so that the first number in first range will be equal to first range in second range, i.e.:
-15.5 = 0,
-15 = 1,
15.5 = 31.
The fixed real range is (-16,16). The non-negative range is <0,64). Amount of numbers is 64. Step is equal 0.25.
-15.75 = 0,
15.75 = 31.
Probably it's just a simple task, but I'm after many hours of hardcore programming and samehow cannot come up with a proper solution.