<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bimsara</title>
    <description>The latest articles on DEV Community by Bimsara (@bimsara_jayasena).</description>
    <link>https://dev.to/bimsara_jayasena</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3574718%2F0a12a98c-0897-418f-9226-32307aad86e6.jpg</url>
      <title>DEV Community: Bimsara</title>
      <link>https://dev.to/bimsara_jayasena</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bimsara_jayasena"/>
    <language>en</language>
    <item>
      <title>Programming foundation - data types at bit level</title>
      <dc:creator>Bimsara</dc:creator>
      <pubDate>Sat, 07 Mar 2026 22:10:37 +0000</pubDate>
      <link>https://dev.to/bimsara_jayasena/programming-foundation-data-types-at-bit-level-31ae</link>
      <guid>https://dev.to/bimsara_jayasena/programming-foundation-data-types-at-bit-level-31ae</guid>
      <description>&lt;p&gt;welcome to this sub article,in here I'm going to talk about data types for little deeper,&lt;/p&gt;

&lt;p&gt;Okay,computers store data as 1 and 0 , we call them 'bit'.when we define data type as int,float etc. we define how much bits that value need,&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;int&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;this can be either 16 bits or 32 bits depending on the system meaning when we store a value as a int,memory will allocate 16 or 32 bits for that value&lt;/p&gt;

&lt;p&gt;eg: int age=25&lt;/p&gt;

&lt;p&gt;if we convert 25 into bits &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Division&lt;/th&gt;
&lt;th&gt;Quotient&lt;/th&gt;
&lt;th&gt;Remainder&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;25 ÷ 2&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12 ÷ 2&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6 ÷ 2&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3 ÷ 2&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1 ÷ 2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Reading the remainders from bottom to top gives us 11001.&lt;/p&gt;

&lt;p&gt;So 25 is stored as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;16-bit: 00000000 00011001&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;32-bit: 00000000 00000000 00000000 00011001&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;float&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;this is for storing decimal numbers and float data type will allocate 32 bits in memory&lt;br&gt;
 1 bit for sign bit &lt;br&gt;
 8 bits for exponent&lt;br&gt;
 23 bits for Mantissa&lt;/p&gt;

&lt;p&gt;eg: float a= 20.5&lt;/p&gt;

&lt;p&gt;let's represent this in bits &lt;br&gt;
first the 20&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Division&lt;/th&gt;
&lt;th&gt;Quotient&lt;/th&gt;
&lt;th&gt;Remainder&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;20 ÷ 2&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10 ÷ 2&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5  ÷ 2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2  ÷ 2&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1  ÷ 2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;20 =&amp;gt; 10100&lt;/p&gt;

&lt;p&gt;then .5&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Multiplication&lt;/th&gt;
&lt;th&gt;result&lt;/th&gt;
&lt;th&gt;Integer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0.5 × 2&lt;/td&gt;
&lt;td&gt;1.0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;.5 =&amp;gt; .1&lt;/p&gt;

&lt;p&gt;so the binary representation of 20.5 will be      &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      10100.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;BUT,we can't store '.' in computer,WHY? computer store only 1 and 0s,computer don't now What The Fish is '.', so we need to &lt;em&gt;normalize&lt;/em&gt; it&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Normalization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;if we want to find the origin of Normalization we have to looked at some scientific maths (don't worry it's not scary...)&lt;/p&gt;

&lt;p&gt;Scientists work with extremely large or small values:&lt;/p&gt;

&lt;p&gt;Distance to sun    = 150,000,000,000 meters&lt;br&gt;
  Size of an atom    = 0.000000000100 meters&lt;br&gt;
  Mass of electron   = 0.000000000000000000000000000000911 kg&lt;/p&gt;

&lt;p&gt;Soo, scientist determined to find a compact, error-free way to write numbers, and that is the &lt;em&gt;normalization&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;in normalization, instead of writing the whole value, we write it like this:&lt;/p&gt;

&lt;p&gt;Size of an atom = 1.0 × 10⁻¹⁰&lt;/p&gt;

&lt;p&gt;This was called &lt;em&gt;Normalized Scientific Notation&lt;/em&gt; . and they made a rule &lt;strong&gt;always exactly 1 non-zero digit before the dot&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Then,The Computers arrived!!!&lt;/p&gt;

&lt;p&gt;and computer have no idea about how to store a decimal number ,when it was given 20.5, and it stored 205.see the problem?why?because it doesn't know how to store a '.',computer only knows about 1s and 0s. &lt;/p&gt;

&lt;p&gt;As a solution, scientist thought "let's do the same thing that we did on paper,let's use normalization for the computer" (idk they actually said that,just guessing).&lt;/p&gt;

&lt;p&gt;let's see how does computer store 20.5 with help of the normalization&lt;/p&gt;

&lt;p&gt;first,when we give 20.5 to computer,it take that number as two parts, integer part (20) and fraction part (.5). then convert them into binary&lt;/p&gt;

&lt;p&gt;20 =&amp;gt; 10100&lt;br&gt;
  5  =&amp;gt; 1&lt;/p&gt;

&lt;p&gt;after that,computer find the first 1 from left side in integer part which we define as &lt;em&gt;left most bit&lt;/em&gt; . in here it is the first bit from left side.&lt;/p&gt;

&lt;p&gt;10100.1 =&amp;gt;1.01001&lt;/p&gt;

&lt;p&gt;then computer count how many bits are there after the &lt;strong&gt;left most bit&lt;/strong&gt; . in here it is 4.&lt;/p&gt;

&lt;p&gt;and that leading bit is hidden and not stored in memory,why? because we exactly now the leading bit is always 1 cannot be 0 or else because this method follow the rule &lt;strong&gt;always exactly 1 non-zero digit before the dot&lt;/strong&gt; in normalization.since computer have only 1 and 0,the &lt;em&gt;non-zero digit&lt;/em&gt; will always 1.so storing it will be waste of memory.&lt;/p&gt;

&lt;p&gt;in normalization process we shifted 4 places,so the exponent is 4 , and Mantissa is 01001&lt;/p&gt;

&lt;p&gt;then computer add bias 127 (IEEE 754 standard) to that exponent,so now exponent will be:&lt;/p&gt;

&lt;p&gt;127+4=131=&amp;gt;10000011&lt;/p&gt;

&lt;p&gt;after that, assemble the fraction part(1) with these,so the final result is:&lt;/p&gt;

&lt;p&gt;0 10000011 01001000000000000000000&lt;/p&gt;

&lt;p&gt;okay,that's how &lt;em&gt;float&lt;/em&gt; data type works,but it has limitation,that is it can only store 32 bits values;&lt;/p&gt;

&lt;p&gt;1 bit for sign bit&lt;br&gt;
   8 bits for exponent&lt;br&gt;
   24 (23 + hidden bit) bits for Mantissa&lt;/p&gt;

&lt;p&gt;23 bits can generate 8,388,608 combinations (2²³),so it can only hold roughly 7 decimal digits of precision, what if we want to store a number with 8 or more precision, then we have to use &lt;em&gt;double&lt;/em&gt; data type&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;double&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;this work as same as float data type but this provide 64 bits instead of 32 &lt;/p&gt;

&lt;p&gt;1 bit for sign bit&lt;br&gt;
  11 bits for exponent&lt;br&gt;
  52 bits for Mantissa&lt;/p&gt;

&lt;p&gt;so it can generate roughly 9,007,199,254,740,991 combinations which mean it can hold up to 16 decimal digits of precision&lt;/p&gt;

&lt;p&gt;Now you understand what's actually happening inside int, float, and double at the hardware level — and why choosing the right data type matters.&lt;/p&gt;

&lt;p&gt;Thank you for reading this far — it genuinely means a lot. I'm still learning and growing as a writer, and your time and support make that journey worthwhile. I hope this gave you something useful to carry forward.Happy Coding 🖥️&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Programming Foundation with C — Article 1: Variables, Data Types &amp; Arrays</title>
      <dc:creator>Bimsara</dc:creator>
      <pubDate>Fri, 06 Mar 2026 16:20:22 +0000</pubDate>
      <link>https://dev.to/bimsara_jayasena/programming-foundation-with-c-article-1-variables-data-types-arrays-66c</link>
      <guid>https://dev.to/bimsara_jayasena/programming-foundation-with-c-article-1-variables-data-types-arrays-66c</guid>
      <description>&lt;p&gt;Welcome to the first article in my "Programming Foundation with C" series.&lt;br&gt;
Before we start writing C code, there are three core concepts you need to understand. Master these and the rest of programming starts to make sense:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Variables&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Data Types&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Arrays&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's get into it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Variables&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you write a program, you almost always need to work with values — names, numbers, scores, ages, whatever. Those values need to live somewhere while your program is running. That somewhere is your computer's memory — the RAM.&lt;br&gt;
A variable is just a named location in that memory. You give it a name so you can find it and use it later.&lt;/p&gt;

&lt;p&gt;Here's the simplest example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

int main() {
    int age = 25;
    printf("%d", age);
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This program stores the number 25 in memory, labels that location age, and prints it. That's it. Clean and simple.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Naming Rules (you must follow these)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Cannot start with a number → 1name ❌&lt;br&gt;
Cannot contain spaces → my age ❌&lt;br&gt;
Cannot be a reserved word → int, for, while ❌&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best Practices (you should follow these)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use meaningful names → age is better than a&lt;br&gt;
Use camelCase or snake_case → userName or user_name&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Data Types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you create a variable, you also have to tell the computer what kind of value you're storing. Is it a whole number? A decimal? A single character? That's what data types are for.&lt;br&gt;
C is strict about this — you can't just throw any value into any variable. You have to declare the type upfront.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Core Data Types&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;What it stores&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;int&lt;/td&gt;
&lt;td&gt;Whole numbers&lt;/td&gt;
&lt;td&gt;25, -7, 1000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;float&lt;/td&gt;
&lt;td&gt;Decimal numbers (single precision)&lt;/td&gt;
&lt;td&gt;.14, -0.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;double&lt;/td&gt;
&lt;td&gt;Decimal numbers (double precision)&lt;/td&gt;
&lt;td&gt;.14,-0.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;char&lt;/td&gt;
&lt;td&gt;A single character&lt;/td&gt;
&lt;td&gt;'A', 'z', '3'&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;double&lt;/strong&gt; - if we want to store values that can have more than 7 decimal points, we should use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int score = 100;
float temperature = 36.6;
char grade = 'A';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Quick summary&lt;/strong&gt;: A variable has three things — a type, a name, and a value. Always define all three clearly.&lt;br&gt;
&lt;a href="https://dev.to/bimsara_jayasena/programming-foundation-data-types-at-bit-level-31ae"&gt;click here if you want to go little bit deeper in data types&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Arrays&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So far we've stored one value per variable. But what if you need to store a list of values — like a full squad of operators?&lt;br&gt;
That's where &lt;em&gt;arrays&lt;/em&gt; come in.&lt;br&gt;
An &lt;em&gt;array&lt;/em&gt; is a collection of values grouped under one variable name. Each value has an index (its position in the list), starting from 0.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;char team[] = {"Price", "Soap", "Gaz", "Ghost"};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Yeah, if you know these guys — you're a real one. And yes, they ruined it.)&lt;/p&gt;

&lt;p&gt;Accessing values by index:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;team[0]  // "Price"
team[1]  // "Soap"
team[2]  // "Gaz"
team[3]  // "Ghost"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⚠️ Note: In most cases, arrays hold values of the same data type. A list of integers, a list of characters — not a mix.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wrapping Up&lt;/strong&gt;&lt;br&gt;
You now know the three building blocks that almost every program is built from:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Variables&lt;/strong&gt; — named locations in memory that hold values&lt;br&gt;
&lt;strong&gt;Data Types&lt;/strong&gt; — define what kind of value a variable holds&lt;br&gt;
&lt;strong&gt;Arrays&lt;/strong&gt; — group multiple values under one name&lt;/p&gt;

&lt;p&gt;These aren't just C concepts — they exist in every programming language. Learning them in C means you're learning them properly, from the ground up.&lt;/p&gt;

&lt;p&gt;Next article, we'll go deeper. Stay tuned.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you found this helpful — or if I got something wrong — drop a comment. Whether you're a beginner or a veteran, I want to hear from you.&lt;br&gt;
Happy coding.&lt;/em&gt; 🖥️&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
