tbowers / aforge

Automatically exported from code.google.com/p/aforge
0 stars 0 forks source link

Math.Tools.IsPowerOf2 returns true when given 0. #167

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Exactly what the summary says.

AForge.Math.Tools.IsPowerOf2(0) returns true, not false; it needs "&& x > 0" 
added to the return condition.

IsPowerOf2 will also return true on -2147483648, hence the choice of 
greater-than rather than not-equal.

Original issue reported on code.google.com by dales...@gmail.com on 18 Oct 2010 at 2:06

GoogleCodeExporter commented 8 years ago

Original comment by andrew.k...@gmail.com on 19 Oct 2010 at 7:00

GoogleCodeExporter commented 8 years ago
Added a check for greater than 0 in IsPowerOf2() function. It will return false 
for everything is which <= 0.

Committed in revision 1333. Will be released in version 2.1.5.

Original comment by andrew.k...@gmail.com on 10 Nov 2010 at 4:18

GoogleCodeExporter commented 8 years ago

Original comment by andrew.k...@gmail.com on 12 Jan 2011 at 11:44