mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-28 20:43:50 +08:00
Documentation for 0fea073413
This commit is contained in:
@@ -139,7 +139,7 @@ Functions</h2></td></tr>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p >Implementation to check whether a number is a power of 2 or not. </p>
|
||||
<p >This algorithm uses bit manipulation to check if a number is a power of 2 or not.</p>
|
||||
<h3><a class="anchor" id="autotoc_md83"></a>
|
||||
<h3><a class="anchor" id="autotoc_md84"></a>
|
||||
Algorithm</h3>
|
||||
<p >Let the input number be n, then the bitwise and between n and n-1 will let us know whether the number is power of 2 or not</p>
|
||||
<p >For Example, If N= 32 then N-1 is 31, if we perform bitwise and of these two numbers then the result will be zero, which indicates that it is the power of 2 If N=23 then N-1 is 22, if we perform bitwise and of these two numbers then the result will not be zero , which indicates that it is not the power of 2 </p><dl class="section note"><dt>Note</dt><dd>This implementation is better than naive recursive or iterative approach.</dd></dl>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 6.0.1 (20220911.1526)
|
||||
<!-- Generated by graphviz version 6.0.2 (20221011.1828)
|
||||
-->
|
||||
<!-- Title: test Pages: 1 -->
|
||||
<svg width="182pt" height="27pt"
|
||||
|
||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 6.0.1 (20220911.1526)
|
||||
<!-- Generated by graphviz version 6.0.2 (20221011.1828)
|
||||
-->
|
||||
<!-- Title: user_input_test Pages: 1 -->
|
||||
<svg width="232pt" height="64pt"
|
||||
|
||||
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 6.0.1 (20220911.1526)
|
||||
<!-- Generated by graphviz version 6.0.2 (20221011.1828)
|
||||
-->
|
||||
<!-- Title: main Pages: 1 -->
|
||||
<svg width="256pt" height="27pt"
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Reference in New Issue
Block a user