Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Binary Numbers System

How data is stored in computers

Tarun Luthra
We humans use a decimal, or base-10, numbering
system, presumably because people have 10
ingers

Early computers were designed around the


decimal numbering system. This approach made
the creation of computer logic capabilities
unnecessarily complex and did not make ef icient
use of resources. (For example, 10 vacuum tubes
were needed to represent one decimal digit.)
f
f
To deal with the basic
electronic states of
on and off, Von
Neumann suggested
using the binary
numbering system
All data is stored in binary numbers

• Images
• Audio
• Videos
How images are stored ?

• Images comprise of thousands


of pixels.
• A pixel is the smallest unit of a
digital image or graphic that
can be displayed and
represented on a digital display
device.
• 1 Megapixel = 1 million pixels
Binary numbers
Decimal to binary

1. Repeatedly divide the number


by 2 till you get 0 and note the
remainders.
2. Take the remainders in reverse
order.
Binary to Decimal

1. Write down the binary number


and list the powers of 2 from
right to left
2. Take the sum of all powers that
have 1 corresponding to them.
2’s complement
Negating a number
How to compute 2’s complement ?

• Invert each bit in the binary


representation.
• Add 1 to the new number.
Homework

• Write pseudocode for converting a decimal number to binary.


• Write pseudocode for converting a binary number to decimal.
Local Setup
Python and Jupyter
Python 3
Check if you already have python installed on your system

• To check, open your terminal/


command prompt.
• Type ‘python’ in it and execute.
• If you get something like this, python
is already installed on your system
and you may skip the installation
steps.
Installing Python
Proceed only if you do not have python already installed

• Windows
• Go to this link - https://www.python.org/downloads/windows/
• Download the latest stable version of installer according to your windows version
and run it.
• MacOS
• Install with homebrew - “brew install python”
• Linux
• Ubuntu, Debian - Install with ‘sudo apt’
• Arch, Manjaro - Install with AUR
Installing Jupyter Notebook
• (Common for all OS)
• Open your terminal/command prompt and execute the following
commands in it.
• pip install jupyterlab
• pip install notebook

• To run Jupyter Notebook, execute


• jupyter notebook

You might also like