scala/scala — pull request #3127 by RajivKurian (2013-11-11 20:04:02+00:00)
Title: Use an intrinsic for the next power of two calculation.

Fixes issues raised in #3126.
The nextPowerOfTwo function is replaced by nextPositivePowerOfTwo which provides the following improvements:

1) Uses the Integer.numberOfLeadingZeros intrinsic for the actual implementation.
2) If the input is already a power of two it just returns the number instead of returning the next power of two.
3) Works for negative numbers and zero as input. The output is 1 in both cases.