Skip to content
Snippets Groups Projects
Commit e6fc135b authored by Karsten Suehring's avatar Karsten Suehring
Browse files

handle x==0 case in ceilLog2()

parent dc6eb6e5
No related branches found
No related tags found
1 merge request!881refactor ceil/floor log2 handling
......@@ -685,6 +685,7 @@ static inline int floorLog2(uint32_t x)
{
if (x == 0)
{
// note: ceilLog2() expects -1 as return value
return -1;
}
#ifdef __GNUC__
......@@ -728,7 +729,7 @@ static inline int floorLog2(uint32_t x)
static inline int ceilLog2(uint32_t x)
{
return floorLog2(x - 1) + 1;
return (x==0) ? -1 : floorLog2(x - 1);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment