Variables and Data types – Storage and size

In this lesson we discuss about the storage of variables in memory and the size of different data types.

Data is stored in binary format (0 or 1) and the basic unit of storage is Bit
Bits can be either 0 or 1
Data is stored in multiple bits
for example 4 bits can store maximum 1111 which is equivalent of 2^4 = 15
For data types which also store negative numbers the left most bit is used to store the sign and the remaining bits to store data.
So in case of 4 bits 3 bits will be used to data.
So the maximum value that can be stored is
0111 = 2^3 = 7
For representing negative numbers there are multiple methods the simple of which is one’s complement.
In ones complete a negative number will be represented by flipping all the bits of the equivalent positive number.
For example 7 is represented below
0111 = 7
To represent -7 we flip all 0 to 1 and 1 to 0
1000 = -7
Here the left most bit has value 1 which indicates this is a negative number.

Characters are represented in same format by converting to their ASCII values.

Why should you learn to code

As i begin this course on learning to code i want to start with reasons why we should be learning to code.

Lot of people would want to learn to code to begin a career in software programming.

But there are many other reasons for learning to code.

Let me tell you a story.

One of my ex colleagues who was very good at programming was originally a real estate developer. He started learning coding because he wanted to build a web site for his real estate company. He acquired useful skills in coding that came to his rescue later in 2008 – 2009 when real estate business crashed. He was able to switch his career in programming. I asked him once if he like coding and he mentioned he likes it because you have the power to create stuff in coding. So true. The story for me outlines a lot of reasons why its a good idea to learn to code even if you don’t plan to have a career in software.

Let me list some out

  • Learn coding for fun
  • Learn to create a web site for your business
  • Learn to create useful applications
  • Learn to create just about anything

So lets get started on this journey.

No comments to show.