NearestPowerOf2

Hi,

the function "FastMath.nearestPowerOfTwo" returns the NEXT power of two and not the nearest.

Example:



If you call FastMath.nearestPowerOfTwo(129) you will get 256! But in my opinion the nearest power of two would be 128 ! Is there a method to calculate the nearest and not the next powerOfTwo ?

For sure, i could simply call FastMath.nearestPowerOfTwo(129) and then FastMath.nearestPowerOfTwo(129/2) and compare the results. The result which is nearest to 129 would be the "nearestPowerOfTwo". But i don't think that this is fast procedure…

Greetings,

Chris