<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Nitesh's Dev Notes]]></title><description><![CDATA[Nitesh's Dev Notes]]></description><link>https://niteshkamat.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1593680282896/kNC7E8IR4.png</url><title>Nitesh&apos;s Dev Notes</title><link>https://niteshkamat.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 08:03:49 GMT</lastBuildDate><atom:link href="https://niteshkamat.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Part 1: Logic & Bit Shifts]]></title><description><![CDATA[Every single decision your c program makes- every if,every while, every return - is your code asking a yes/no question and branching on the answer
logic is the math of yes/no questions thats's it. Tha]]></description><link>https://niteshkamat.hashnode.dev/logic-bit-shifts</link><guid isPermaLink="true">https://niteshkamat.hashnode.dev/logic-bit-shifts</guid><category><![CDATA[logic]]></category><dc:creator><![CDATA[Nitesh Kamat]]></dc:creator><pubDate>Mon, 21 Sep 2026 05:33:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6ab0361e998dd670eece9b99/3c64c2f7-ac18-492b-97a7-766db22e867d.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Every single decision your c program makes- every if,every while, every return - is your code asking a yes/no question and branching on the answer</p>
<p>logic is the math of yes/no questions thats's it. That's the whole subject. Everything below is just formalizing something you already do instinctively when you write code.</p>
<h3>Propositions - statement that are True or false that's it there is no uncertainties in this it holds one truth that's all</h3>
<p>Examples:</p>
<ul>
<li><p>"7 is greater than 3" -&gt; True.</p>
</li>
<li><p>"Kathmandu is the capital of Nepal"-&gt; True.</p>
</li>
<li><p>"2 + 2 = 5" -&gt; False.</p>
</li>
</ul>
<p>Not propositions (because they're not statements with a fixed truth value)</p>
<ul>
<li><p>"What time is it?"(a question , not a statement)</p>
</li>
<li><p>"close the command"(a command)</p>
</li>
<li><p>"x + 5 = 10" ( depends on x - it's only a proposition once x has an actual value).</p>
</li>
</ul>
<h3>why should you care as a C Programmer?</h3>
<p>Every single if condition you write is a proposition .</p>
<pre><code class="language-c">int x = 7;
if(x&gt;5){ //this is a proposition
  printf("big\n"); //true
} 
</code></pre>
<p>In C, True is represented as 1 ( or more precisely "any non-zero value") , and false is 0. That's why this works</p>
<pre><code class="language-c">int result = (x&gt;5) ; //result is literally 1 because proposition is True
printf("%d\n",result);
</code></pre>
<p>So basically we've been creating and evaluation propositions this whole time without naming them. Now you've the name.</p>
<h3>2 . The operators - Combining propositions</h3>
<p>You rarely have just one condition . You combine them . There are 4 you'll use constantly</p>
<p><code>AND( ^ ) -C : &amp;&amp;</code></p>
<p><code>OR ( V ) - C : ||</code></p>
<pre><code class="language-plaintext">P  Q  P AND Q(both must be true)   P  Q  P OR Q (one must be true)
T  T   T                           T  T    T
F  F   F                           F  F    F
F  T   F                           T  F    T 
T  F   F                           F  T    T

P   !p(NOT)                        P   Q   P X-OR Q
T    F                             F   F    F
F    T                             T   T    F
                                   T   F    T
                                   F   T    T
</code></pre>
<h3>3 . DE - MORGAN'S LAWS</h3>
<p><code>&gt;(P ^ Q) == &gt;P V &gt;Q</code> - this means "NOT(P and Q)" == NOT(P) OR NOT(Q)</p>
<p><code>&gt;(P V Q) == &gt;P ^ &gt;Q</code> - this means "NOT(P OR Q)" == NOT(P) AND NOT(Q)</p>
<h3>Why a C Programmer needs this : (DE MORGAN) ?</h3>
<p>Validating input and the difference between "reject bad Input" and "accept good input"</p>
<pre><code class="language-c">int x = 50 , has_permission = 1;
//say you want to REJECT anything that isn't (in range AND has permission)

if(!(x &gt;=0 &amp;&amp; x&lt;=100 &amp;&amp; has_permission)){
    printf("Rejected\n");
}
</code></pre>
<p>This works , but nested (!) around a long &amp;&amp; chain is genuinely hard to read when you're debugging . DE-MORGAN lets you write it.</p>
<pre><code class="language-c">if(x &lt; 0 || x&gt;100 || !has_permission){
   printf("Rejected\n");
}
</code></pre>
<p>Both version are 100% equivalent same truth value table but the second one reads naturally : " reject if too small , OR Too big , OR no permission"</p>
]]></content:encoded></item></channel></rss>