Sunday 12 February 2012

How BITs and BYTEs works?

BIT stands  for Binary Digits. To understand it, lets first understand how decimal number works. Decimal numbers are combination of few digits. A digit is a single place that can hold numerical values between 0 and 9.
For example in the four digit number 3427, 7 fills the "1s place", while 2 fills the "10s place", 4 fills the "100s place and 3 fills the "1000s place". So we can express the number 3427 as :
(3*1000)+(4*100)+(2*10)+(7*1)=3000+400+20+1=3427

We can also express it in the powers of 10 as 
(3*10^3)+(4*10^2)+(2*10^1)+(7*10^0)=3000+400+20+1=3427:
Decimal number are therefore " base-10 number systems".

Computer operates on "base-2 number system" and it is also known as "binary number system" as it has only two possible values "0 and 1" unlike decimal numbers having values "0 till 9". Each is called as bits.

For the 1110 binary number we can find the corresponding decimal number in the way we did for 3427 as:
(1*2^3)+(1*2^2)+(1*2^1)+(0*2^0)=8+4+2+0=14.



Starting at zero and going through 20, counting in decimal and binary looks like this:

0 = 0
1 = 1
2 = 10
3 = 11
4 = 100
5 = 101
6 = 110
7 = 111
8 = 1000
9 = 1001
10 = 1010
11 = 1011
12 = 1100
13 = 1101
14 = 1110
15 = 1111

Now what is BYTE? Well, it is just a collection of 8 bits. We can simply say 8 bits makes 1 byte like 12 eggs makes one dozen of eggs. With 8 bits in a byte, you can represent 256 values ranging from 0 to 255, as shown below:

0 = 00000000
1 = 00000001
2 = 00000010
3 = 00000011
...
254 = 11111110
255 = 11111111

Bytes are frequently used to hold individual characters in a text document. In the ASCII character set, each binary value between 0 and 127 is given a specific character. Most computers extend the ASCII character set to use the full range of 256 characters available in a byte.

Computers store text documents, both on diskand in memory, using these codes. For example, if you use Notepad in windows and  create a text file containing the words, "My name is John" Notepad would use 1 byte of memory per character (including 1 byte for each space character between the words).

Try this: Open a notepad and type "My name is John" without codes and save the notepad as try.txt. Now check the file size. It will be 15 bytes.

If you were to look at the file as a computer looks at it, you would find that each byte contains not a letter but a number --the number is the ASCII code corresponding to the character. So on disk, the numbers for the file try.txt  look like this:
M    y              n    a     m     e             i      s             J      o     h       n.
77  121  32  110  97  109  101  32  105  115  32  74   111  104  110

Standard ASCII Character Set are as follows:

0 NUL
1       SOH
2       STX
3       ETX
4       EOT
5       ENQ
6       ACK
7       BEL
8       BS
9       TAB
10     LF
11     VT
12     FF
13     CR
14     SO
15     SI
16     DLE
17     DC1
18     DC2
19     DC3
20     DC4
21     NAK
22     SYN
23     ETB
24     CAN
25     EM
26     SUB
27     ESC
28     FS
29     GS
30     RS
31     US
32
33     !
34     "
35     #
36      $
37     %
38     &
39     '
40     (
41      )
42      *
43      +
44     ,
45     -
46     .
47     /
48     0
49     1
50     2
51     3
52     4
53     5
54     6
55     7
56     8
57     9
58     :
59     ;
60     <
61     =
62      >
63     ?
64     @
65     A
66     B
67     C
68     D
69     E
70     F
71     G
72     H
73     I
74      J
75     K
76     L
77     M
78     N
79     O
80     P
81     Q
82     R
83     S
84     T
85     U
86     V
87     W
88     X
89      Y
90     Z
91     [
92     \
93     ]
94     ^
95     _
96      `
97     a
98     b
99     c
100    d
101    e
102    f
103    g
104    h
105    i
106    j
107    k
108    l
109    m
110    n
111    o
112    p
113    q
114    r
115    s
116    t
117    u
118    v
119    w
120    x
121    y
122    z
123    {
124    |
125    }
126    ~
127    DEL




Like any other units, bytes can also be expressed as kilo bytes, mega bytes as shown below.

Kilo Bytes expressed as KB  is equal to  2^10 = 1,024 bytes.
Mega Bytes expressed as MB is equal to 2^20 = 1,048,576 bytes.
Giga Bytes expressed as GB is equal to 2^30 = 1,073,741,824 bytes.
Tera Bytes expressed as TB is equal to 2^40 = 1,099,511,627,776 bytes.
Peta Bytes expressed as PB is equal to 2^50 = 1,125,899,906,842,624 bytes.
Exa Bytes expressed as EB is equal to  2^60 = 1,152,921,504,606,846,976 bytes
Zetta Bytes expressed as ZB is equal to 2^70 = 1,180,591,620,717,411,303,424 bytes
Yotta Bytes expressed as YB is equal to 2^80 = 1,208,925,819,614,629,174,706,176 bytes

No comments:

Post a Comment