Download presentation
Presentation is loading. Please wait.
1
Comp Org & Assembly Lang
Bits and Bytes Topics Why bits? Representing information as bits Binary / Hexadecimal Byte representations Numbers Characters and strings Instructions Bit-level manipulations Boolean algebra Expressing in C
2
Why Don’t Computers Use Base 10?
Base 10 Number Representation That’s why fingers are known as “digits” Natural representation for financial transactions Floating point number cannot exactly represent $1.20 Even carries through in scientific notation X (1.5213e4)
3
Why Don’t Computers Use Base 10?
Implementing Electronically Hard to store ENIAC (First electronic computer) used 10 vacuum tubes / digit IBM 650 used 5+2 bits (1958, successor to IBM’s Personal Automatic Computer, PAC from 1956) Hard to transmit Need high precision to encode 10 signal levels on single wire Messy to implement digital logic functions Addition, multiplication, etc.
4
Binary Representations
Base 2 Number Representation Represent as Represent as [0011]…2 Represent X 104 as X 213 Electronic Implementation Easy to store with bistable elements Reliably transmitted on noisy and inaccurate wires 0.0V 0.5V 2.8V 3.3V 1
5
Encoding Byte Values Byte = 8 bits Binary 000000002 to 111111112
Decimal: to First digit must not be 0 in C Octal: to Use leading 0 in C Hexadecimal to FF16 Base 16 number representation Use characters ‘0’ to ‘9’ and ‘A’ to ‘F’ Use leading 0x in C, write FA1D37B16 as 0xFA1D37B Or 0xfa1d37b 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 A 10 1010 B 11 1011 C 12 1100 D 13 1101 E 14 1110 F 15 1111 Hex Decimal Binary
6
Bases Every number system uses a base Decimal numbers use base 10
Other common bases used in computer science: Octal (base 8) Hexadecimal (base 16) Binary (base 2) Do examples of base 10, base 8 numbers, base 16 Show how to translate base 8 to base 10, base 16 to base 10
7
Decimal x x x 100
8
Octal x x x 80
9
Counting in octal
10
Converting Converting octal to decimal:
753 = 7 x x x 80 = = 491
11
Translating to octal writing 157 in base 8
remainder: 2 x x x 80 = = 157 Divisor
12
Hexadecimal x x x 160
13
Hexadecimal A B C D E F A 1B 1C 1D 1E 1F A 2B 2C 2D 2E 2F A 3B 3C 3D 3E 3F 40 41 A 4B 4C 4D 4E 4F 50 A 5B 5C 5D 5E 5F A 6B 6C 6D 6E 6F A 7B 7C 7D 7E 7F A 8B 8C 8D 8E 8F A 10B 10C 10D 10E 10F 120 …
14
Translating to hex 365 remainder: 16 22 D 1 6 0 1 1 6 D
1 6 D 1 x x D x 160 = = 365
15
Binary x x x 20
16
Counting in binary
17
Translating to binary 4 remainder: 1 0 0 1 Divisor
18
Translating to binary remainder: 2 1 1 0 0 1
19
Literary Hex Common 8-byte hex filler: 0xdeadbeef
Can you think of other 8-byte fillers?
20
Relation between hex and binary
Hexadecimal: 16 characters, Each represents a number between 0 and 15 Binary: Consider 4 places Represent numbers between 0000 and 1111 Or between 0 and 15 Result: 1 hex digit represents 4 binary digits
21
Relation between hex and binary
Decimal 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 10 A 1010 11 B 1011 12 C 1100 13 D 1101 14 E 1110 15 F 1111 16
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.