I am using the map() function in my project to convert from an analogRead() value to a PWM value (0-255).
map(analogRead(a0), 0, 1023, 0, 255);
I found that this code did not provide full resolution of the PWM output. Output skipped by approximately 3 steps, minimum, such as: 255, 252, 250, 247, 244... This was surprising, because the "from" range is 4x as big as the "to" range, so surely there is enough precision there to achieve 1-step resolution on the output. So I changed the code to:
map(analogRead(a0), 0, 1023 * 2, 0, 255 * 2);
And it works perfectly! I get sub-1-PWM-step resolution on the output. So I thought I'd pass that along to anybody who needs to map between two ranges of disparate size and wants to increase the effective resolution of the mapping. The exact multiplier required will depend on the relative size of the ranges, I think. I kind of expected that r1 / r2 would end up being the necessary multiplier, but it wasn't. I guess you just have to inject enough resolution to clear up the rounding errors, and you're good.