diff --git a/base/assert/uint32-is-pow2/README.md b/base/assert/uint32-is-pow2/README.md index 1fe10a660..485c1fd32 100644 --- a/base/assert/uint32-is-pow2/README.md +++ b/base/assert/uint32-is-pow2/README.md @@ -72,6 +72,98 @@ for ( i = 0; i < 100; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/assert/uint32_is_pow2.h" +``` + +#### stdlib_base_uint32_is_pow2( x ) + +Tests whether an unsigned integer is a power of 2. + +```c +#include + +bool out = stdlib_base_uint32_is_pow2( 5 ); +// returns false + +out = stdlib_base_uint32_is_pow2( 2 ); +// returns true +``` + +The function accepts the following arguments: + +- **x**: `[in] uint32_t` input value. + +```c +bool stdlib_base_uint32_is_pow2( const uint32_t x ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/assert/uint32_is_pow2.h" +#include +#include +#include + +int main( void ) { + const uint32_t x[] = { 0, 1, 2, 3, 4, 5, 8, 10, 16, 1024 }; + bool b; + int i; + + for ( i = 0; i < 9; i++ ) { + b = stdlib_base_uint32_is_pow2( x[ i ] ); + printf( "Value: %u. is a power of 2? %s.\n", x[ i ], ( b ) ? "True" : "False" ); + } +} +``` + +
s + + + +
+ + +