<Tr> <Td> 1000000000000 </Td> <Td> 4,096 </Td> </Tr> <P> As demonstrated above, the algorithm yields the correct value of 4,096 . The nearest power to 2,689 happens to be 2,048; however, this algorithm is designed only to give the next highest power of two to a given number, not the nearest . </P> <P> Another way of obtaining the' next highest' power of two to a given number independent of the length of the bitspace is as follows . </P> <P> For any integer, x and integral power of two, y, if z = y - 1, </P>

Function to find the given number is a power of 2 or not