Add non-power-of-two check to GenericMath.

Signed-off-by: Nick Minkler <sleaker@gmail.com>
Merge pull request #2229 from Sleaker/master

Add non-power-of-two check to GenericMath.