<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>EmbLogic &#187; BIT</title>
	<atom:link href="https://www.emblogic.com/blog/tag/bit/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.emblogic.com/blog</link>
	<description>Embedded System and ARM Training</description>
	<lastBuildDate>Tue, 03 Mar 2020 13:00:06 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>Problem with bit wise operators</title>
		<link>https://www.emblogic.com/blog/04/problem-with-bit-wise-operators/</link>
		<comments>https://www.emblogic.com/blog/04/problem-with-bit-wise-operators/#comments</comments>
		<pubDate>Sun, 08 Apr 2012 07:01:59 +0000</pubDate>
		<dc:creator><![CDATA[nitin.sharma]]></dc:creator>
				<category><![CDATA[Data Structures with C]]></category>
		<category><![CDATA[BIT]]></category>
		<category><![CDATA[oprators]]></category>

		<guid isPermaLink="false">http://emblogic.org/blog/?p=2364</guid>
		<description><![CDATA[I am trying to pad two characters in num and trying to print the num in bit pattern.But I am getting -1 instead of 1; Output is for 65 &#8211; it should be 01000001 but i am getting 0-100000-1 sample &#8230; <a href="https://www.emblogic.com/blog/04/problem-with-bit-wise-operators/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I am trying to pad two characters in num and trying to print the num in bit pattern.But I am getting -1 instead of 1;<br />
Output is<br />
for 65 &#8211; it should be 01000001<br />
but i am getting 0-100000-1<br />
sample program is :-</p>
<p>/*padding ytwo char*/</p>
<p>#include&lt;stdio.h&gt;<br />
#include&lt;string.h&gt;<br />
#include&lt;stdlib.h&gt;</p>
<p>void char_pad();<br />
void bit_representation( int num);</p>
<p>int main()<br />
{<br />
char_pad();<br />
}<br />
void char_pad()<br />
{<br />
int num =0;<br />
char ch;<br />
printf(&#8220;enter first char :&#8221;);<br />
ch = getchar();<br />
num = num &lt;&lt; 8;<br />
num = num | ch;<br />
printf(&#8220;num is : %d\n&#8221;,num);<br />
while( getchar() != &#8216;\n&#8217;);</p>
<p>printf(&#8220;enter second char :&#8221;);<br />
ch = getchar();<br />
num = num &lt;&lt;8;<br />
num = num | ch;<br />
printf(&#8220;num is : %d\n&#8221;,num);<br />
bit_representation(num);<br />
}</p>
<p>void bit_representation( int num)<br />
{<br />
int temp,loc;<br />
int i,j;<br />
for(i=0; i&lt;4; i++)<br />
{<br />
temp = num;<br />
temp = temp &lt;&lt;(8 * i);</p>
<p>temp = temp &gt;&gt;(24)<br />
printf(&#8220;temp is : %d\n&#8221;,temp);<br />
for(j=0; j&lt;8; j++)<br />
{<br />
loc = temp;</p>
<p>loc = loc &lt;&lt; (24 +j);<br />
loc = loc &gt;&gt;31;<br />
printf(&#8220;%d&#8221;,loc);<br />
}<br />
printf(&#8220;\n&#8221;);<br />
}<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/04/problem-with-bit-wise-operators/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
