If I have a number greater than 20, but this can be divided by 2 without any residues, I want to determine which number is closest to me 20. For example:
During 2048, dividing by 2 would increase me enough to 16, which is closest to 20. If the number is 800, the closest is 25.
I can write a loop and just continue to share and compare the range and choose the closest value. Maybe a simpler way, perhaps by bit shifting?
EDIT: When I say that it is evenly divisible by 2, I mean that it divides everything to two. A number of 70 would only divide up to 35 evenly. A number equal to 2048 or 1024 will be evenly distributed to 2.
Examples of numbers: 2048, 1920, 1600, 1536, 1080..640, 352, 320, 176. These are typical sizes of images from cameras.
source share