diff options
Diffstat (limited to 'pacman-c++/util.cpp')
| -rw-r--r-- | pacman-c++/util.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pacman-c++/util.cpp b/pacman-c++/util.cpp index b1848e1..2a3b78a 100644 --- a/pacman-c++/util.cpp +++ b/pacman-c++/util.cpp | |||
| @@ -248,6 +248,20 @@ namespace Util | |||
| 248 | return data; | 248 | return data; |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | int floorLog2(unsigned int n) | ||
| 252 | { | ||
| 253 | if (n == 0) | ||
| 254 | return -1; | ||
| 255 | |||
| 256 | int pos = 0; | ||
| 257 | if (n >= 1<<16) { n >>= 16; pos += 16; } | ||
| 258 | if (n >= 1<< 8) { n >>= 8; pos += 8; } | ||
| 259 | if (n >= 1<< 4) { n >>= 4; pos += 4; } | ||
| 260 | if (n >= 1<< 2) { n >>= 2; pos += 2; } | ||
| 261 | if (n >= 1<< 1) { pos += 1; } | ||
| 262 | return pos; | ||
| 263 | } | ||
| 264 | |||
| 251 | #if 0 | 265 | #if 0 |
| 252 | void hexdump(void *pAddressIn, long lSize) | 266 | void hexdump(void *pAddressIn, long lSize) |
| 253 | { | 267 | { |
