Using concept of "n&(n-1)" makes value = 0 if n is number with power of 2
#include <stdio.h>
int nextPwrOf2(int num)
{
do
{
#include <stdio.h>
int nextPwrOf2(int num)
{
do
{
Tricks,Tips, Tweaks of Embedded C, C, Micro-controllers, Peripherals, Compilers, Datasheets, Linux, RTOS and Embedded Communication Protocols.