Skip to content
Snippets Groups Projects
Commit 1e438147 authored by Karsten Suehring's avatar Karsten Suehring Committed by Jizheng Xu
Browse files

handle x==0 case in ceilLog2()

parent 18b909c9
No related branches found
No related tags found
No related merge requests found
......@@ -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