Re:Ten Ways to Check if an Integer Is a Power Of Two in C
by vog on Wednesday July 27, 2011 @09:30AM
(#2812019)
According to the C spec, this is expression is undefined for v == 0.
So it might return true, or return false, or start NetHack, or wipe your disk. In other words: Strictly speaken, that function is not allowed to be called for v == 0.
Re:Ten Ways to Check if an Integer Is a Power Of Two in C
by MostAwesomeDude on Thursday July 28, 2011 @09:39AM
(#2816714)
Mesa is a GL renderer. POT only matters in 3D for things like texture sizes. Textures aren't allowed to have zero-sized dimensions. The check for v == 0 occurs far higher up the stack than where this function's used.
We're not writing bad code, we promise. :3
Further, this technique - correctly applied - is essentially #9 in the list.