shift the value 2 places to the right.... 10bits shift >> 2, 8 bits....
shift the value 2 places to the right.... 10bits shift >> 2, 8 bits....
Dave Purola,
N8NTA
EN82fn
If you simply shift out the least significant bits you lose any small variations between values
that might not have occurred with a divide, but then when you multiply back to the original range
you also drop resolution.
You can calculate a new range like this:
NewValue = (((OriginalValue - OriginalMin) * (NewMax - NewMin)) / (OriginalMax - OriginalMin)) + NewMin
Unless I am missing the obvious. Shifting right by two, or dividing by two (integer division) is identical. The only difference should be in speed. Shifts should always be faster, and divides may be slower depending on the compiler optimization.
Lanquer, That is correct...
Dave Purola,
N8NTA
EN82fn
Ignore my whole post... don't know where my head was,
you're going to drop the same resolution anyway!
Correct me if I'm wrong but if you divide a 10 bit result by 2, you get a 9 bit result. EG 1024/2 = 512. 8 bit max is 256 so you'd have to divide it by 4.
you're correct, thiswas my hands playing catchup with the brainor dividing by two
Bookmarks