Bit,s, Bytes and Number Systems- Decimal, Binary, Hexadecimal ... [PDF]

Feb 22, 2004 - In the denary binary octal hexadecimal systems, the value of any digit in a number depends on its positio

5 downloads 22 Views 85KB Size

Recommend Stories


Bits & Bytes
No amount of guilt can solve the past, and no amount of anxiety can change the future. Anonymous

Bits, Bytes, and Integers
The wound is the place where the Light enters you. Rumi

Bits and Bytes
Goodbyes are only for those who love with their eyes. Because for those who love with heart and soul

bits and bytes
You have to expect things of yourself before you can do them. Michael Jordan

Bits, Bytes, and Nibbles
Don't count the days, make the days count. Muhammad Ali

How Bits and Bytes Work
In the end only three things matter: how much you loved, how gently you lived, and how gracefully you

Chapter 2 Binary Values and Number Systems
The butterfly counts not months but moments, and has time enough. Rabindranath Tagore

Correctly Rounded Floating-point Binary-to-Decimal and Decimal-to-Binary Conversion Routines
Pretending to not be afraid is as good as actually not being afraid. David Letterman

NUMBER SYSTEMS AND CODES [PDF]
Octal system has certain advantages in digital work because it requires less circuitry to get information into and out of a digital system. Moreover, it is easier to read, record and print out octal numbers than binary numbers. Hexadecimal number sys

pdf,302832 bytes)
You're not going to master the rest of your life in one day. Just relax. Master the day. Than just keep

Idea Transcript


Bits Bytes and Number Systems- Binary, Denary, Hexadecimal, Octal and ASCII Codes tutorial Back

Programming Tutorial

Updated 22 Feb 2004 Tutorials: HTML and Web Design | C programming | Smalltalk Programming

Contents Number Systems How do numbering systems work Denary Sometimes called Decimal Binary How to Convert binary to denary Hexadecimal Octal

Introduction Bit Byte Kilobyte Megabyte ASCII Codes This table is useful to compare values of the different numbering systems.

Binary System

Introduction This tutorial is going to assist you with the different numbering systems that are used in programming. Programmers will need to be familiar with most of them. You are already familiar with our every day denary numbering system based on the unit 10. Computers only understand the binary number system based on the unit 2 denary. Programming often uses the hexadecimal system base on a unit of 16 denary. For example HTML uses hexadecimal numbering in the color attribute, e.g. color="FF00FF". Another less common system is octal based on 8 denary. You should know how to convert between the different systems. The ASCII table at the foot of this page is useful for a quick conversions up to 127 denary. The windows calculator (in scientific mode) can be used for conversions. College and University students may find that calculators are not allowed in the exam, OU course T223 is an example of this, therefore manual conversion calculations must be made. This should be practiced to speed up the process, the calculator only used to check your manual conversion.

Bit A binary digit is called a bit. Usually expressed as 0 and 1 the two numbers of the binary numbering system. A bit is the smallest unit of information a computer can use. A 16 bit computer would process a series of 16 bits,such as 0100111101011000 in one go, repeating the process thousands or millions of times per second. Reading a series of bits is very difficult and to make this process easier they are often displayed in groups of 4 bits 0100 1111 0101 1000 This grouping is quite interesting in that a group of 4 bits can be replaced by a single hexadecimal digit Two groups of 4 bits, i.e. 8 bits ( a byte) can be replaced by 2 hexadecimal digits, and 4 hexadecimal digits are required to replace all 16 bits. Binary

0100

1111

0101

1000

4

F

5

8

Hexadecimal

Byte A group of 8 bits are in a byte. With 8 bits ( binary digits ), there exists 256 possible denary combinations. If you remember that 1 byte can store one alphabetical letter, single digit, or a single character/symbol, such as #. Large numbers of bytes can be expressed by kilobytes, megabytes etc 1 byte of memory can normally hold one of the following: a single alphabetical letter (upper or lower case), a single number 0-9 a symbol ( _ + £ # > etc a further 127 alternative characters. These could be the letters used in foreign languages, lines to produce boxes etc. See the ASCII codes at the foot of this page which shows how the first 127 characters of 256 characters are used

Kilobyte The value of a kilobyte is 1024. Worked out as 2^ 10. Normally Kilo refers to 1000 but in computing kilobyte is 1024.

Top

Megabyte (MB) Likewise, 1024Kb is referred to as a "Megabyte". Normally a Mega refers to a million. In computing 1 Mega byte is 1,048,576 bytes. Worked out as 220, or 1024*1024. A megabyte can store roughly 4 books of 200 pages

Gigabyte (GB) A Gigabyte is 1,073,741,824 (230) bytes. 1,024 Megabytes, or 1,048,576 Kilobytes. A gigabyte can store almost 4500 books of 200 pages You could store 1 but not 2 650MB CDs

Terabyte (TB) A Terabyte is 1,099,511,627,776 (240) bytes, 1,024 Gigabytes, or 1,048,576 Megabytes.

Petabyte (PB) 250 bytes

Exabyte (EB) 260 bytes bytes

Number Systems The every day number system we use is the denary system, sometimes called the decimal system. In programming three number systems are commonly used, binary, hexadecimal and to a lesser extent octal . In every day life we Usually use the denary number system which has a base of 10. But we also use other number systems, think of time (base 60, and base 10 within it), imperial distance yards and feet (base 3), there are many others, dates probably being the hardest number system to do calculations with. In the denary binary octal hexadecimal systems, the value of any digit in a number depends on its position within that number. I.e. which column it is in.

How do numbering systems work To understand this we will examine the Denary system in more detail. Because you are so used to the denary system and because it is very easy to multiply by 10, 100, or a 1000 etc you calculate the number in your head. Lets use the number 256 as an example. The calculation that is automatically done is the following The most important calculation to do is to work out the positional values for that system. The positional value is based on the powers of the number systems base value 104

103

102

10x10x10x10

10x10x10

10x10

10,000

1000

100

10

10,000

1000

100

10

1

10,000

1000

100

10

1

2

5

6

100

10

1

2

5

6

Power of the base Calculation = Position value

101

100

The value of the base number Any number to the power 0 is always 1 1

Write down the Positional values for the number system you are using so for Denary we would write Position value Underneath the correct positional value write in your number Position value Enter Number The calculation that is done Position value

10,000

1000

Enter Number Required Calculation





100x2

10x5

1x6

This equals





200

50

6

Add the 3 results 200 + 50 + 6 200 50 6 ____ 256 You can convert a number in any number system to a denary number using this calculation. Ensure you use the positional values for the number system you are using

Denary Numbering (base 10) sometimes called Decimal system The decimal system name should not be used because of confusion that this could be thought as introducing the decimal point and money systems Uses numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, that's 10 numbers. Hence base 10. Radix is another name for base 10. Adding 1 to 9 we must introduce an additional column to the left i.e. 10 104

103

102

101

100

10,000

1000

100

10

1

Power of the base Position value A byte of memory can store a number in the range 0 to 255 Denary.

Top

Binary Numbering (base 2) A series of eight bits strung together makes a byte, much as 12 makes a dozen. With 8 bits, or 8 binary digits, there exist 2^8=256 possible combinations Uses numbers 0, 1,, that's 2 numbers. Hence base 2. Binary numbering is the number system that is used by computers. Note: The positional value doubles as you go to the next positional on the left Power of the base

24

23

22

21

20

Positional value

16

8

4

2

1

A binary digit is called a bit. There are two possible states in a bit, Usually expressed as 0 and 1, the two numbers used in the binary number system. But the bit could represent on / off of an electrical circuit, yes / no, true / false, -1 / 0, -1 / +1, zero / non zero, or similar 2 state binary wording. A byte of memory can store a number in the range 00000000 to 11111111 binary. Numbers are often displayed in groups of 4, as follows, to make them easier to read. 0000 0000 to 1111 1111 binary.

How to Convert Binary to Denary Convert 1011 binary to denary Positional value

16

8

4

2

1

Enter Number



1

0

1

1

Required Calculation



8x1

4x0

2x1

1x1

This equals



8

0

2

1

Add the 3 results 8 + 0 + 2 + 1 8 0 2 1 ____ 11 Therefore 1011(One Zero One One) binary = 11 (Eleven) Denary

Top

Hexadecimal Numbering (base 16) Uses numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, that's 16 numbers. Hence base 16.. A=10 Dec, B=11 DEC, C=12 DEC, D=13 DEC, E=14 DEC, F=15 Dec. By using the letters A-F a single digit only requires a single position (column). Power of the base Positional value

164

163

162

161

160

65536

4,096

256

16

1

A byte of memory can store a number in the range 00 to FF Hex Hexadecimal numbers are often displayed in groups of 2, to make them easier to read. E.g. 10 AF 3C 9F A single hexadecimal number requires 4 units of binary numbers. This makes it reasonably easy to convert between these two numbering systems. E.g. 1 = 0001 9 = 0101 A = 1010

Top

Octal (base 8) Uses numbers 0, 1, 2, 3, 4, 5, 6, 7, , that's 8 numbers. Hence base 8.. A byte of memory can store a number in the range 0 to 377 Oct. 84

83

82

81

80

4096

512

64

8

1

Power of the base Positional value

Binary Systems The Binary system is used by digital devices such as computers. Consists of two possible states such as On - Off, Yes - No, True - False, Zero - Non Zero and possibly more confusing in programming -1 and 0. These states are usually represented by either the number 0 or 1 of the binary number system. Back Top

ASCII Codes ASCII DEC Hex Octal

Binary

ASCII Dec Hex Octal

Binary

ASCII Dec Hex Octal

Binary

NULL

000

00

000

0000 0000

+

043

2B

053

0010 1011

V

086

56

126

0101 0110

SOH

001

01

001

0000 0001

,

044

2C

054

0010 1100

W

087

57

127

0101 0111

STX

002

02

002

0000 0010

-

045

2D

055

0010 1101

X

088

58

130

0101 1000

ETX

003

03

003

0000 0011

.

046

2E

056

0010 1110

Y

089

59

131

0101 1001

EOT

004

04

004

0000 0100

/

047

2F

057

0010 1111

Z

090

5A

132

0101 1010

ENQ

005

05

005

0000 0101

0

048

30

060

0011 0000

[

091

5B

133

0101 1011

ACK

006

06

006

0000 0110

1

049

31

061

0011 0001

\

092

5C

134

0101 1100

BEL

007

07

007

0000 0111

2

050

32

062

0011 0010

]

093

5D

135

0101 1101

BS

008

08

010

0000 1000

3

051

33

063

0011 0011

^

094

5E

136

0101 1110

HT

009

09

011

0000 1001

4

052

34

064

0011 0100

_

095

5F

137

0101 1111

LF

010

0A

012

0000 1010

5

053

35

065

0011 0101

`

096

60

140

0110 0000

VT

011

0B

013

0000 1011

6

054

36

066

0011 0110

a

097

61

141

0110 0001

FF

012

0C

014

0000 1100

7

055

37

067

0011 0111

b

098

62

142

0110 0010

CR

013

0D

015

0000 1101

8

056

38

070

0011 1000

c

099

63

143

0110 0011

SO

014

0E

016

0000 1110

9

057

39

071

0011 1001

d

100

64

144

0110 0100

SI

015

0F

017

0000 1111

:

058

3A

072

0011 1010

e

101

65

145

0110 0101

DLE

016

10

020

0001 0000

;

059

3B

073

0011 1011

f

102

66

146

0110 0110

DC1

017

11

021

0001 0001

a

060

3C

074

0011 1100

g

103

67

147

0110 0111

DC2

018

12

022

0001 0010

=

061

3D

075

0011 1101

h

104

68

150

0110 1000

DC3

019

13

023

0001 0011

>

062

3E

076

0011 1110

i

105

69

151

0110 1001

DC4

020

14

024

0001 0100

?

063

3F

077

0011 1111

j

106

6A

152

0110 1010

NAK

021

15

025

0001 0101

@

064

40

100

0100 0000

k

107

6B

153

0110 1011

SYN

022

16

026

0001 0110

A

065

41

101

010 00001

l

108

6C

154

0110 1100

ETB

023

17

027

0001 0111

B

066

42

102

0100 0010

m

109

6D

155

0110 1101

CAN

024

18

030

0001 1000

C

067

43

103

0100 0011

n

110

6E

156

0110 1110

EM

025

19

031

0001 1001

D

068

44

104

0100 0100

o

111

6F

157

0110 1111

SUB

026

1A

032

0001 1010

E

069

45

105

0100 0101

p

112

70

160

0111 0000

ESC

027

1B

033

0001 1011

F

070

46

106

0100 0110

q

113

71

161

0111 0001

FS

028

1C

034

0001 1100

G

071

47

107

0100 0111

r

114

72

162

0111 0010

GS

029

1D

035

0001 1101

H

072

48

110

0100 1000

s

115

73

163

0111 0011

RS

030

1E

036

0001 1110

I

073

49

111

0100 1001

t

116

74

164

0111 0100

US

031

1F

037

0001 1111

J

074

4A

112

0100 1010

u

117

75

165

0111 0101

space

032

20

040

0010 0000

K

075

4B

113

0100 1011

v

118

76

166

0111 0110

!

033

21

041

0010 0001

L

076

4C

114

0100 1100

w

119

77

167

0111 0111

"

034

22

042

0010 0010

M

077

4D

115

0100 1101

x

120

78

170

0111 1000

#

035

23

043

0010 0011

N

078

4E

116

0100 1110

y

121

79

171

0111 1001

$

036

24

044

0010 0100

O

079

4F

117

0100 1111

z

122

7A

172

0111 1010

%

037

25

045

0010 0101

P

080

50

120

010 10000

{

123

7B

173

0111 1011

&

038

26

046

0010 0110

Q

081

51

121

0101 0001

|

124

7C

174

0111 1100

'

039

27

047

0010 0111

R

082

52

122

0101 0010

}

125

7D

175

0111 1101

(

040

28

050

0010 1000

S

083

53

123

0101 0011

~

126

7E

176

0111 1110

)

041

29

051

0010 1001

T

084

54

124

0101 0100

DEL

127

7F

177

0111 1111

*

042

2A

052

0010 1010

U

085

55

125

0101 0101

Top.

Smile Life

When life gives you a hundred reasons to cry, show life that you have a thousand reasons to smile

Get in touch

© Copyright 2015 - 2024 PDFFOX.COM - All rights reserved.