Binary Numbers in C++

Binary Numbers: The Best format for computer to understand, write, code, and decode. These numbers have just Base 2.

Originally published in en
Reactions 0
1115
DT
DT 14 Jan, 2020 | 1 min read

Why Binary Number has Base 2?

 

Binary Numbers has Base “2” that means it consists of two numbers “0” and “1”. Binary Language is a language in which a computer communicates between themselves. The various functioning taking place inside a computer is on hardware level.

So, we cannot store the files inside a Computer Memory or it cannot be created. So, the numbers are stored in form of Cells

For Example:

If any particular cells have “+V” charge then, 1 is being stored.

If any particular cells have “+0” charge then, 0 is being stored.

In a Binary format numbers are stored in a form of 0 and 1.

The operators which work on Binary Numbers are as follows:

1.      And

2.      Or

3.      Exclusive Or

4.      Not

5.      Left Shift

6.      Right Shift

The above-mentioned operator works at Bit Level.

Converting a Binary Number into Decimal Number

 

Binary Number: 1111

12^3 + 12^2 + 12^1 + 12^0

Each of the number present at bits level is multiplied with a power of 2 increasing each time

Decimal Number: 15

 

Converting a Decimal Number into Binary Number

 

Decimal Number: 5

5 % 2 = 1 ; 5 / 2 = 2

2 % 2 =0 ;  2 / 2 =1

1 % 2 = 1 ; 1/ 2 = 0

Each time a the quotient is modulus by 2 and the remainder is then taken in reverse order when final digit is 0.

0 likes

Published By

DT

DT

Comments

Appreciate the author by telling what you feel about the post 💓

Please Login or Create a free account to comment.