<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 3.8 &#8212; Bitwise operators</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/</link>
	<description></description>
	<lastBuildDate>Fri, 12 Mar 2010 16:52:45 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: prashant ganesha</title>
		<link>http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/comment-page-1/#comment-79973</link>
		<dc:creator>prashant ganesha</dc:creator>
		<pubDate>Sun, 07 Mar 2010 14:03:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/#comment-79973</guid>
		<description>i had read a c++ book..i dint have this kind of satisfaction after reading the book.. its truly amazing..thank you guru alex.. god bless you..</description>
		<content:encoded><![CDATA[<p>i had read a c++ book..i dint have this kind of satisfaction after reading the book.. its truly amazing..thank you guru alex.. god bless you..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zak</title>
		<link>http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/comment-page-1/#comment-62946</link>
		<dc:creator>Zak</dc:creator>
		<pubDate>Tue, 23 Jun 2009 18:02:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/#comment-62946</guid>
		<description>So if you did (7 &gt;&gt; 2), you get from 0111 to 0001, which is the number 1. Now how can you get back from that to 7? So the main use for this is so noone understands it except for the person who changed the value? To me, these bitwise operators seem useless except for Bitwise Not (~). I really do not understand what good you can get out of doing 5&#124;6.</description>
		<content:encoded><![CDATA[<p>So if you did (7 &gt;&gt; 2), you get from 0111 to 0001, which is the number 1. Now how can you get back from that to 7? So the main use for this is so noone understands it except for the person who changed the value? To me, these bitwise operators seem useless except for Bitwise Not (~). I really do not understand what good you can get out of doing 5|6.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DB</title>
		<link>http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/comment-page-1/#comment-61754</link>
		<dc:creator>DB</dc:creator>
		<pubDate>Mon, 01 Jun 2009 01:48:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/#comment-61754</guid>
		<description>How about a simple encryption program? Have a secret list of passwords in a text file? Render it useless to hackers with a simple changing of 0&#039;s to 1&#039;s, and 1&#039;s to 0&#039;s! (this both encrypts and unencrypts it):

#include fstream
#include iostream

using namespace std;

int main()
{
	char choice[250];
	fstream file;
	cout &lt;&gt; choice;  //EDIT: this is wtf scrweed up by the site.. youi know how to use cin I assume &gt;.&gt;
      
	file.open(choice, ios::binary &#124; ios::in);
	if (!file.is_open())
		return 0;
	char *data;
	long begin, end, size;
	file.seekg(0, ios::beg);
	begin = file.tellg();
	file.seekg(0, ios::end);
	end = file.tellg();
	size = end - begin;
	data = new char[size];
	file.seekg(0, ios::beg);
	file.read(data, size);
	file.close();
	for (long i = 0; i &lt; size; i++)
		data[i] = ~data[i];
	file.open(&quot;output.woo&quot;, ios::out &#124; ios::binary);
	file.seekp(0, ios::beg);
	file.write(data, size);

	return 0;
}</description>
		<content:encoded><![CDATA[<p>How about a simple encryption program? Have a secret list of passwords in a text file? Render it useless to hackers with a simple changing of 0&#8217;s to 1&#8217;s, and 1&#8217;s to 0&#8217;s! (this both encrypts and unencrypts it):</p>
<p>#include fstream<br />
#include iostream</p>
<p>using namespace std;</p>
<p>int main()<br />
{<br />
	char choice[250];<br />
	fstream file;<br />
	cout &lt;&gt; choice;  //EDIT: this is wtf scrweed up by the site.. youi know how to use cin I assume &gt;.&gt;</p>
<p>	file.open(choice, ios::binary | ios::in);<br />
	if (!file.is_open())<br />
		return 0;<br />
	char *data;<br />
	long begin, end, size;<br />
	file.seekg(0, ios::beg);<br />
	begin = file.tellg();<br />
	file.seekg(0, ios::end);<br />
	end = file.tellg();<br />
	size = end &#8211; begin;<br />
	data = new char[size];<br />
	file.seekg(0, ios::beg);<br />
	file.read(data, size);<br />
	file.close();<br />
	for (long i = 0; i &lt; size; i++)<br />
		data[i] = ~data[i];<br />
	file.open(&#8221;output.woo&#8221;, ios::out | ios::binary);<br />
	file.seekp(0, ios::beg);<br />
	file.write(data, size);</p>
<p>	return 0;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DB</title>
		<link>http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/comment-page-1/#comment-61751</link>
		<dc:creator>DB</dc:creator>
		<pubDate>Sun, 31 May 2009 23:47:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/#comment-61751</guid>
		<description>An easy example is in things like compression.. you can easily add 0&#039;s and 1&#039;s to things like characters.

An easy use to display the &lt;&gt; operators:

You have a character. Display its binary. Using bitwise &lt;&gt;, it is quite easy to.

char decode = (somesortofcharactefgettingthinghere);
char tempChar;
for (int i = 0; i &lt; 8; i++) // we are using a character. It is 1 byte, or 8 bits (or is on my computer).
{
   tempChar = decode
   tempChar &lt;&lt; i;
   tempChar &gt;&gt; 7;      // because bits are lost, we can seperate 0&#039;s and 1&#039;s by themselves.
   cout &lt;&lt; char;
}

I can&#039;t easily explain that, but if you think it out in your head...

lets say our character is the number 97 (I think thats A, but it does not matter. It is only outputted as A, internally it is a number)

0 1 1 0 0 0 0 1

Alright, in our loop, we start by shifting it 0 units to the left. we then shift it to the right 7.

Our result? 0. Next time, move it 1 unit to the left, 7 to the right. 1. So on and so forth. You could have alternatively used a calculation, but this was just an example.</description>
		<content:encoded><![CDATA[<p>An easy example is in things like compression.. you can easily add 0&#8217;s and 1&#8217;s to things like characters.</p>
<p>An easy use to display the &lt;&gt; operators:</p>
<p>You have a character. Display its binary. Using bitwise &lt;&gt;, it is quite easy to.</p>
<p>char decode = (somesortofcharactefgettingthinghere);<br />
char tempChar;<br />
for (int i = 0; i &lt; 8; i++) // we are using a character. It is 1 byte, or 8 bits (or is on my computer).<br />
{<br />
   tempChar = decode<br />
   tempChar &lt;&lt; i;<br />
   tempChar &gt;&gt; 7;      // because bits are lost, we can seperate 0&#8217;s and 1&#8217;s by themselves.<br />
   cout &lt;&lt; char;<br />
}</p>
<p>I can&#8217;t easily explain that, but if you think it out in your head&#8230;</p>
<p>lets say our character is the number 97 (I think thats A, but it does not matter. It is only outputted as A, internally it is a number)</p>
<p>0 1 1 0 0 0 0 1</p>
<p>Alright, in our loop, we start by shifting it 0 units to the left. we then shift it to the right 7.</p>
<p>Our result? 0. Next time, move it 1 unit to the left, 7 to the right. 1. So on and so forth. You could have alternatively used a calculation, but this was just an example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JTO</title>
		<link>http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/comment-page-1/#comment-61081</link>
		<dc:creator>JTO</dc:creator>
		<pubDate>Mon, 18 May 2009 23:48:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/#comment-61081</guid>
		<description>Hey Alex, This site is great. Do you know any site that with give an example to try this stuff out.
Thanks alot.</description>
		<content:encoded><![CDATA[<p>Hey Alex, This site is great. Do you know any site that with give an example to try this stuff out.<br />
Thanks alot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CompNerd</title>
		<link>http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/comment-page-1/#comment-59603</link>
		<dc:creator>CompNerd</dc:creator>
		<pubDate>Thu, 30 Apr 2009 19:50:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/#comment-59603</guid>
		<description>I&#039;m looking to create a new PRNG, and I need to be able to assign individual bits within a byte... Is there a way to decide what each bit will be within a byte without changing the other bits, and without finding out what symbol (letter/number/other) uses the specific binary code I need and then assigning it?</description>
		<content:encoded><![CDATA[<p>I&#8217;m looking to create a new PRNG, and I need to be able to assign individual bits within a byte&#8230; Is there a way to decide what each bit will be within a byte without changing the other bits, and without finding out what symbol (letter/number/other) uses the specific binary code I need and then assigning it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sunilla</title>
		<link>http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/comment-page-1/#comment-38557</link>
		<dc:creator>sunilla</dc:creator>
		<pubDate>Wed, 21 Jan 2009 19:19:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/#comment-38557</guid>
		<description>&lt;pre&gt; i want to write the bits on an output file, that is supposed to be compressed file of an original file using the huffman technique just like if the code for A is 110, then i want to write these 3-bits on output file. how can i manage it.from the above mentioned explanations i got an idea about bit manipulation but i still dont get the complete idea of resolving my issue.&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<pre> i want to write the bits on an output file, that is supposed to be compressed file of an original file using the huffman technique just like if the code for A is 110, then i want to write these 3-bits on output file. how can i manage it.from the above mentioned explanations i got an idea about bit manipulation but i still dont get the complete idea of resolving my issue.</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/comment-page-1/#comment-37102</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Sun, 11 Jan 2009 22:44:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/#comment-37102</guid>
		<description>In ASCII, upper case and lower case letters are separated by 32 bits.  As he says, 65=&#039;A&#039;, 97=&#039;a&#039;.  &#039;a&#039;-&#039;A&#039; = 32.  By XORing 32 onto a lower or upper case letter, we can convert it from lower case to upper case or vice versa.</description>
		<content:encoded><![CDATA[<p>In ASCII, upper case and lower case letters are separated by 32 bits.  As he says, 65=&#8217;A', 97=&#8217;a&#8217;.  &#8216;a&#8217;-'A&#8217; = 32.  By XORing 32 onto a lower or upper case letter, we can convert it from lower case to upper case or vice versa.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abhisek</title>
		<link>http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/comment-page-1/#comment-36923</link>
		<dc:creator>Abhisek</dc:creator>
		<pubDate>Sat, 10 Jan 2009 05:37:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/#comment-36923</guid>
		<description>I couldn&#039;t understand the above comment.
Why he has mentioned of the digit 32 ?

Please make it clear...</description>
		<content:encoded><![CDATA[<p>I couldn&#8217;t understand the above comment.<br />
Why he has mentioned of the digit 32 ?</p>
<p>Please make it clear&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jeff</title>
		<link>http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/comment-page-1/#comment-36003</link>
		<dc:creator>jeff</dc:creator>
		<pubDate>Wed, 31 Dec 2008 08:40:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/#comment-36003</guid>
		<description>thanks to you alex, i learned the operation of bitwise operators but i dont know where can i use it. can you give me a site of example for program application.</description>
		<content:encoded><![CDATA[<p>thanks to you alex, i learned the operation of bitwise operators but i dont know where can i use it. can you give me a site of example for program application.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
