mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-23 13:22:47 +08:00
Documentation for 8b1eab204b
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
<!-- HTML header for doxygen 1.12.0-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||
<head>
|
||||
@@ -5,10 +6,15 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.12.0"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: others/decimal_to_binary.cpp File Reference</title>
|
||||
<title>TheAlgorithms/C++: others/decimal_to_binary.cpp File Reference</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../jquery.js"></script>
|
||||
<script type="text/javascript" src="../../dynsections.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
|
||||
<script type="text/javascript">
|
||||
DoxygenAwesomeDarkModeToggle.init()
|
||||
</script>
|
||||
<script type="text/javascript" src="../../clipboard.js"></script>
|
||||
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../navtreedata.js"></script>
|
||||
@@ -18,14 +24,24 @@
|
||||
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../search/searchdata.js"></script>
|
||||
<script type="text/javascript" src="../../search/search.js"></script>
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
|
||||
jax: ["input/TeX","output/HTML-CSS"],
|
||||
});
|
||||
<script type="text/javascript">
|
||||
window.MathJax = {
|
||||
options: {
|
||||
ignoreHtmlClass: 'tex2jax_ignore',
|
||||
processHtmlClass: 'tex2jax_process'
|
||||
},
|
||||
loader: {
|
||||
load: ['[tex]/ams']
|
||||
},
|
||||
tex: {
|
||||
macros: {},
|
||||
packages: ['base','configmacros','ams']
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
|
||||
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
|
||||
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
@@ -33,10 +49,11 @@ MathJax.Hub.Config({
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr id="projectrow">
|
||||
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
|
||||
<td id="projectalign">
|
||||
<div id="projectname">Algorithms_in_C++<span id="projectnumber"> 1.0.0</span>
|
||||
<div id="projectname">TheAlgorithms/C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">Set of algorithms implemented in C++.</div>
|
||||
<div id="projectbrief">All the algorithms implemented in C++</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -118,7 +135,9 @@ Include dependency graph for decimal_to_binary.cpp:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d7/dae/decimal__to__binary_8cpp__incl.svg" width="200" height="111"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
</div><table class="memberdecls">
|
||||
</div>
|
||||
<p><a href="../../df/d06/decimal__to__binary_8cpp_source.html">Go to the source code of this file.</a></p>
|
||||
<table class="memberdecls">
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
|
||||
Functions</h2></td></tr>
|
||||
<tr class="memitem:a9240f2e79074a2a248395258aebbfa11" id="r_a9240f2e79074a2a248395258aebbfa11"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="#a9240f2e79074a2a248395258aebbfa11">method1</a> (int number)</td></tr>
|
||||
@@ -130,6 +149,8 @@ Functions</h2></td></tr>
|
||||
</table>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p>Function to convert decimal number to binary representation. </p>
|
||||
|
||||
<p class="definition">Definition in file <a class="el" href="../../df/d06/decimal__to__binary_8cpp_source.html">decimal_to_binary.cpp</a>.</p>
|
||||
</div><h2 class="groupheader">Function Documentation</h2>
|
||||
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">◆ </a></span>main()</h2>
|
||||
@@ -145,20 +166,20 @@ Functions</h2></td></tr>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../df/d06/decimal__to__binary_8cpp_source.html#l00046">46</a> of file <a class="el" href="../../df/d06/decimal__to__binary_8cpp_source.html">decimal_to_binary.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 46</span> {</div>
|
||||
<div class="line"><span class="lineno"> 47</span> <span class="keywordtype">int</span> number;</div>
|
||||
<div class="line"><span class="lineno"> 48</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Enter a number:"</span>;</div>
|
||||
<div class="line"><span class="lineno"> 49</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> >> number;</div>
|
||||
<div class="line"><span class="lineno"> 48</span> std::cout << <span class="stringliteral">"Enter a number:"</span>;</div>
|
||||
<div class="line"><span class="lineno"> 49</span> std::cin >> number;</div>
|
||||
<div class="line"><span class="lineno"> 50</span> </div>
|
||||
<div class="line"><span class="lineno"> 51</span> <a class="code hl_function" href="#a9240f2e79074a2a248395258aebbfa11">method1</a>(number);</div>
|
||||
<div class="line"><span class="lineno"> 52</span> <a class="code hl_function" href="#a10df57491019f0ac39b492740fb388f7">method2</a>(number);</div>
|
||||
<div class="line"><span class="lineno"> 53</span> </div>
|
||||
<div class="line"><span class="lineno"> 54</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><span class="lineno"> 55</span>}</div>
|
||||
<div class="ttc" id="abasic_istream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a></div></div>
|
||||
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
|
||||
<div class="ttc" id="adecimal__to__binary_8cpp_html_a10df57491019f0ac39b492740fb388f7"><div class="ttname"><a href="#a10df57491019f0ac39b492740fb388f7">method2</a></div><div class="ttdeci">void method2(int number)</div><div class="ttdef"><b>Definition</b> decimal_to_binary.cpp:27</div></div>
|
||||
<div class="ttc" id="adecimal__to__binary_8cpp_html_a9240f2e79074a2a248395258aebbfa11"><div class="ttname"><a href="#a9240f2e79074a2a248395258aebbfa11">method1</a></div><div class="ttdeci">void method1(int number)</div><div class="ttdef"><b>Definition</b> decimal_to_binary.cpp:11</div></div>
|
||||
<div class="ttc" id="adecimal__to__binary_8cpp_html_a10df57491019f0ac39b492740fb388f7"><div class="ttname"><a href="#a10df57491019f0ac39b492740fb388f7">method2</a></div><div class="ttdeci">void method2(int number)</div><div class="ttdef"><b>Definition</b> <a href="../../df/d06/decimal__to__binary_8cpp_source.html#l00027">decimal_to_binary.cpp:27</a></div></div>
|
||||
<div class="ttc" id="adecimal__to__binary_8cpp_html_a9240f2e79074a2a248395258aebbfa11"><div class="ttname"><a href="#a9240f2e79074a2a248395258aebbfa11">method1</a></div><div class="ttdeci">void method1(int number)</div><div class="ttdef"><b>Definition</b> <a href="../../df/d06/decimal__to__binary_8cpp_source.html#l00011">decimal_to_binary.cpp:11</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
@@ -177,25 +198,20 @@ Functions</h2></td></tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p>This method converts the bit representation and stores it as a decimal number. </p>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../df/d06/decimal__to__binary_8cpp_source.html#l00011">11</a> of file <a class="el" href="../../df/d06/decimal__to__binary_8cpp_source.html">decimal_to_binary.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 11</span> {</div>
|
||||
<div class="line"><span class="lineno"> 12</span> <span class="keywordtype">int</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/remainder.html">remainder</a>, binary = 0, var = 1;</div>
|
||||
<div class="line"><span class="lineno"> 12</span> <span class="keywordtype">int</span> remainder, binary = 0, var = 1;</div>
|
||||
<div class="line"><span class="lineno"> 13</span> </div>
|
||||
<div class="line"><span class="lineno"> 14</span> <span class="keywordflow">do</span> {</div>
|
||||
<div class="line"><span class="lineno"> 15</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/remainder.html">remainder</a> = number % 2;</div>
|
||||
<div class="line"><span class="lineno"> 15</span> remainder = number % 2;</div>
|
||||
<div class="line"><span class="lineno"> 16</span> number = number / 2;</div>
|
||||
<div class="line"><span class="lineno"> 17</span> binary = binary + (<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/numeric/math/remainder.html">remainder</a> * var);</div>
|
||||
<div class="line"><span class="lineno"> 17</span> binary = binary + (remainder * var);</div>
|
||||
<div class="line"><span class="lineno"> 18</span> var = var * 10;</div>
|
||||
<div class="line"><span class="lineno"> 19</span> } <span class="keywordflow">while</span> (number > 0);</div>
|
||||
<div class="line"><span class="lineno"> 20</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Method 1 : "</span> << binary << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 20</span> std::cout << <span class="stringliteral">"Method 1 : "</span> << binary << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 21</span>}</div>
|
||||
<div class="ttc" id="aendl_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a></div><div class="ttdeci">T endl(T... args)</div></div>
|
||||
<div class="ttc" id="aremainder_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/remainder.html">std::remainder</a></div><div class="ttdeci">T remainder(T... args)</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../df/d06/decimal__to__binary_8cpp_a9240f2e79074a2a248395258aebbfa11_cgraph.svg" width="202" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
<a id="a10df57491019f0ac39b492740fb388f7" name="a10df57491019f0ac39b492740fb388f7"></a>
|
||||
@@ -213,6 +229,8 @@ Here is the call graph for this function:</div>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p>This method stores each bit value from LSB to MSB and then prints them back from MSB to LSB </p>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../df/d06/decimal__to__binary_8cpp_source.html#l00027">27</a> of file <a class="el" href="../../df/d06/decimal__to__binary_8cpp_source.html">decimal_to_binary.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 27</span> {</div>
|
||||
<div class="line"><span class="lineno"> 28</span> <span class="keywordtype">int</span> num_bits = 0;</div>
|
||||
<div class="line"><span class="lineno"> 29</span> <span class="keywordtype">char</span> bit_string[50];</div>
|
||||
@@ -226,17 +244,12 @@ Here is the call graph for this function:</div>
|
||||
<div class="line"><span class="lineno"> 37</span> number >>= 1; <span class="comment">// right shift bit 1 bit</span></div>
|
||||
<div class="line"><span class="lineno"> 38</span> } <span class="keywordflow">while</span> (number > 0);</div>
|
||||
<div class="line"><span class="lineno"> 39</span> </div>
|
||||
<div class="line"><span class="lineno"> 40</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Method 2 : "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 40</span> std::cout << <span class="stringliteral">"Method 2 : "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 41</span> <span class="keywordflow">while</span> (num_bits >= 0)</div>
|
||||
<div class="line"><span class="lineno"> 42</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << bit_string[num_bits--]; <span class="comment">// print from MSB to LSB</span></div>
|
||||
<div class="line"><span class="lineno"> 43</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/manip/endl.html">std::endl</a>;</div>
|
||||
<div class="line"><span class="lineno"> 42</span> std::cout << bit_string[num_bits--]; <span class="comment">// print from MSB to LSB</span></div>
|
||||
<div class="line"><span class="lineno"> 43</span> std::cout << std::endl;</div>
|
||||
<div class="line"><span class="lineno"> 44</span>}</div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../df/d06/decimal__to__binary_8cpp_a10df57491019f0ac39b492740fb388f7_cgraph.svg" width="202" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- contents -->
|
||||
|
||||
Reference in New Issue
Block a user