DEV Community

daVfn
daVfn

Posted on • Updated on

Binary numbers

Binary numbers are a way of representing numerical values using only two symbols (0,1). This system is called base-2, because it uses two digits. Each position in a binary number represents a power of 2, much like how each position in a decimal number represents a power of 10.

Common Uses of Binary Numbers:

Binary is fundamental to how computers operate. All data processed by computers, such as text, images, and numbers, are represented and manipulated using binary code.
Also Files, images, audio, and videos on digital media (like hard drives or flash drives) are stored in binary format.

Binary operations

How to do basic mathematical operations with Binary numbers. Here’s an overview of how binary addition, subtraction, multiplication, and division work.

Binary Addition

Just like with decimals, we add binary numbers column by column from the right. For example-1101 + 1011:

1101

  • 1011

=11000

Start from the rightmost column:
1 + 1 = 10 (write 0 and carry 1)
Continue to the left, keeping track of carries.
The result is 11000.

Binary Subtraction

Binary subtraction is also straightforward. If we need to borrow, we take a 1 from the left column:
For example-1001 - 0100:
1001

  • 0100

= 0101

1 - 0 = 1
0 - 1: borrow from the next column, making 2 - 1 = 1.
The result is 101.

Binary Multiplication

Binary multiplication is the same as decimal multiplication. Multiply and then add the results.
For example-1010 x 0110:

1010
x 0110

=111100

Binary Division

Binary division is the same as decimal division, divide, subtract, bring down the next digit.

For example-11100 / 101:

11100 / 101 = 110

Top comments (0)