|
|
/* $Id$ */
|
|
|
|
|
|
/** @file bitmath_func.cpp Functions related to bit mathematics. */
|
|
|
|
|
|
#include "../stdafx.h"
|
|
|
#include "bitmath_func.hpp"
|
|
|
|
|
|
const uint8 _ffb_64[64] = {
|
|
|
0, 0, 1, 0, 2, 0, 1, 0,
|
|
|
3, 0, 1, 0, 2, 0, 1, 0,
|
|
|
4, 0, 1, 0, 2, 0, 1, 0,
|
|
|
3, 0, 1, 0, 2, 0, 1, 0,
|
|
|
5, 0, 1, 0, 2, 0, 1, 0,
|
|
|
3, 0, 1, 0, 2, 0, 1, 0,
|
|
|
4, 0, 1, 0, 2, 0, 1, 0,
|
|
|
3, 0, 1, 0, 2, 0, 1, 0,
|
|
|
0, 0, 1, 0, 2, 0, 1, 0,
|
|
|
3, 0, 1, 0, 2, 0, 1, 0,
|
|
|
4, 0, 1, 0, 2, 0, 1, 0,
|
|
|
3, 0, 1, 0, 2, 0, 1, 0,
|
|
|
5, 0, 1, 0, 2, 0, 1, 0,
|
|
|
3, 0, 1, 0, 2, 0, 1, 0,
|
|
|
4, 0, 1, 0, 2, 0, 1, 0,
|
|
|
3, 0, 1, 0, 2, 0, 1, 0,
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* Search the first set bit in a 32 bit variable.
|
|
|
*
|
|
|
* This algorithm is a static implementation of a log
|
|
|
* conguence search algorithm. It checks the first half
|
|
|
* if there is a bit set search there further. And this
|
|
|
* way further. If no bit is set return 0.
|
|
|
*
|
|
|
* @param x The value to search
|
|
|
* @return The position of the first bit set
|