Commit b989ea71 authored by ahoms's avatar ahoms
Browse files

* using (nice DFC) IsPowerOf2 for binning checking


git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@12 45c4679d-1946-429d-baad-37912b19538b
parent 55bcc877
......@@ -7,6 +7,20 @@
namespace lima
{
/*******************************************************************
* \fn IsPowerOf2(x)
* \brief Calculates if a given number is a power of 2
*
* This very nice implementation was taken from David Fernandez
*******************************************************************/
inline bool IsPowerOf2(int x)
{
return (x > 0) && (((x - 1) & x) == 0);
}
/*******************************************************************
* \class Point
* \brief Basic two-dimension arithmetic class
......@@ -172,7 +186,7 @@ class Bin
inline bool Bin::isValid(int i)
{
return (i > 0);
return IsPowerOf2(i);
}
inline Point Bin::checkValid(const Point& p)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment