MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / IsPowerOf2

Function IsPowerOf2

include/bmpread/bmpread.c:496–508  ·  view source on GitHub ↗

Returns whether a non-negative integer is a power of 2. */

Source from the content-addressed store, hash-verified

494/* Returns whether a non-negative integer is a power of 2.
495 */
496static int IsPowerOf2(uint32_t x)
497{
498 while(x)
499 {
500 /* When we find a bit, return whether no other bits are set. */
501 if(x & 1)
502 return !(x & ~UINT32_C(1));
503 x = x >> 1;
504 }
505
506 /* 0, the only value for x which lands us here, isn't a power of 2. */
507 return 0;
508}
509
510/* Returns the byte length of a scan line padded as necessary to be divisible
511 * by four. For example, 3 pixels wide at 24 bpp would yield 12 (3 pixels * 3

Callers 1

ValidateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected