bits and bytes explained in the computer network.
In the computer network data is transferred from one location to another. When you buy an Internet pack from a Mobile Network Operator. The data pack comes with the volume of data and a validity time.
For example, if the plan includes One Gigabyte (GB) data per day, means in 24 hours you can send and receive One GB of data over the telecom network using your mobile phone.
But how do you know how much data is sufficient for you and how much approx data you may be used in a day? For that, we need to understand the units for data transfer. In this tutorial, we are explaining the most basic units known as bits and bytes in the computer network.
What is a Bit?
It is the smallest unit of information either stored in a computer memory or transfer over the network. You can think of it as a Boolean flag that can be either true or false. Inside a computer, we know them 0 and 1. At the physical level, these are electric signals, zero means low voltage, and one means high voltage.
As per the OSI model, the physical layer converts bits into actual eclectic signals and vice versa. Following are the properties of a bit.
- It is a Boolean type to represent the smallest unit of data.
- It can store either 0 or 1.
- With n number of bits, there can be 2^n possible patterns for example
- Number of bits = 1, possible patterns(2) 0 and 1.
- Number of bits = 2, possible patterns(4) 00 , 01,10 and 11.
- Number of bits = 3, possible patterns(0) 000 , 001, 010,011, 100,101,110 and 111
- You can apply bitwise operators on bits e.f XOR etc.
- A user generally to not bother much about at bit level.
What is a byte?
A byte is the next bigger unit after a bit. A byte contains 8 bits that make a total of 256 values a byte can store. From bytes, we can compose other units, such as Kilobytes, Megabytes, Gigabytes, etc.
- 1 Kilobyte = 1000 Bytes
- 1Megabyte = 1000 Kilobytes.
- 1 Gigabyte = 1000 Megabytes.
- 1 Terabyte = 1000 Gigabytes.
Computer Programming with bits and bytes:
A computer program is a set of instructions. While execution instructions execute one by one. A program may do calculations on the stored data e.g adding two numbers etc. The values are stored in variables of different sizes. The unit of size is bits. For example, if we see all data types in programming languages there are various types.
- char – One Byte
- short Two Bytes
- int – four bytes
- long 8 bytes.
A programming language provides all necessary operators to access and manipulate bits and bytes via a computer program.