Welcome to Gaia! :: View User's Journal | Gaia Journals

 
 

View User's Journal

TimmyAzai's Memories
Well I like to talk about anything, stories, papers, current news.
DATA REPRESENTATION IN THE COMPUTER
There are only 10 different kinds of people in the world: those who know binary and those who don't" -- Source unknown

Any single bit can either be on or off (1 or 0). Thus, data in the computer can be represented in binary form only. Binary numbers are then stored in memory locations of pre-determined sizes. Decimal numbers can be represented by converting to binary. To do this for yourself, successively divide by 2, storing the remainders in reverse order. For example, for the number eleven:

11 / 2 = 5 R 1 in reverse order this gives 1011
5 / 2 = 2 R 1
2 / 2 = 1 R 0 Thus, 11 in decimal is 1011 in binary
1 / 2 = 0 R 1

To change binary to decimal simply note that each digit in a binary number has a place value. The right-most bit, or least significant bit, has a place value of 1 (20). The next bit from the right has a place value of 2 (21); the next, 4 (2¾), etc. Thus, the number 1011 is (1 x 1) + (1 x 2) + (0 x 4) + (1 x cool = 1 + 2 + 8 = 11.

base: largest single digit: only possible digits:
2 binary 1 0 1
8 octal 7 0 1 2 3 4 5 6 7
10 decimal 9 0 1 2 3 4 5 6 7 8 9
16 hexadecimal F (15) 0 1 2 3 4 5 6 7 8 9 A B C D E F

For convenience, binary digits are grouped into segments of eight, called a byte (e.g. 10010011). Since looking at only zero's and one's is quite tedious for humans, binary is often translated to octal (base cool or hexadecimal (base sixteen).

Since the largest number held in three digits of binary (111 = 7) is the same as the largest number held in one digit of octal, we can make a straight conversion by grouping binary digits in threes:

1100100101001010 =
(1)(100)(100)(101)(001)(010) =
144512(octal)


Likewise, we can group binary digits in fours for conversion to Hexadecimal:

1100100101001010 =
(1100)(1001)(0100)(1010) =
C94A(hex)


Hex conversion is handiest for computer use, since a byte (8 bits) can be written with two hexadecimal digits, each representing half of a byte, called a nibble:

00110111 =
(0011)(0111) =
37(hex)
Conversion Table
binary octal decimal hexadecimal
0 0 0 0
1 1 1 1
10 2 2 2
11 3 3 3
100 4 4 4
101 5 5 5
110 6 6 6
111 7 7 7
1000 10 8 8
1001 11 9 9
1010 12 10 A
1011 13 11 B
1100 14 12 C
1101 15 13 D
1110 16 14 E
1111 17 15 F
10000 20 16 10





Negative numbers can be stored by using a signed-number format. For signed numbers, the left-most (most significant) bit is used to hold the sign. If this bit is 0, the number is positive, and we treat it as a normal binary number, as described above. If the most-significant digit is 1, we then treat the signed number as negative by looking at the two's complement of the number. The two's complement is found by taking the logical NOT of the number (the one's complement) and adding 1.
_________________________________________________________________
For example, the number 11111111 begins with a 1, so is treated as negative.

NOT(11111111) = 00000000
00000000 + 1 = 00000001

Therefore 11111111 represents -00000001, or -1.

___________________________________________________________________





 
 
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum