Last change
on this file since 139 was
88,
checked in by rosiere, 16 years ago
|
Almost complete design
with Test and test platform
|
-
Property svn:keywords set to
Id
|
File size:
438 bytes
|
Rev | Line | |
---|
[88] | 1 | #ifndef Morpheo_Log2_h |
---|
| 2 | #define Morpheo_Log2_h |
---|
[63] | 3 | |
---|
| 4 | /* |
---|
| 5 | * $Id: Log2.h 88 2008-12-10 18:31:39Z rosiere $ |
---|
| 6 | * |
---|
| 7 | * [ Description ] |
---|
| 8 | * |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | #include <stdint.h> |
---|
| 12 | #include <math.h> |
---|
| 13 | |
---|
| 14 | namespace morpheo { |
---|
| 15 | |
---|
| 16 | inline uint32_t log2 (uint32_t value) |
---|
| 17 | { |
---|
| 18 | return static_cast<uint32_t>(ceil(::log2(value))); |
---|
| 19 | } |
---|
| 20 | |
---|
[67] | 21 | inline bool is_log2 (uint32_t value) |
---|
| 22 | { |
---|
| 23 | return (value == static_cast<uint32_t>((1<<(morpheo::log2(value))))); |
---|
| 24 | } |
---|
| 25 | |
---|
[63] | 26 | }; // end namespace morpheo |
---|
| 27 | |
---|
| 28 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.