This action might not be possible to undo. Are you sure you want to continue?

Number representation

Computers store numbers, text, .... (any data) in binary

computers are just electrical circuits binary numbers (1, 0) are indications of voltage levels through these circuits (1 = “high”, 0 = “low”)

¡ ¡

**Binary representation of numerical data
**

April 14, 2004

**Text, audio, video: later Numbers: need to represent
**

integers reals (decimal values) negative and positive numbers

¡ ¡ ¡

Integers

Base-10 integers: have a series of digits whose value depends on the relative position of these digits

e.g. 543 = 5 100's, 4 10's, 3 1's = 5*102 + 4*101 + 3*100 e.g. 13245 = 1*104 + 3*103 + 2*102 + 4*101 + 5*100

¡ ¡ ¡ ¡

Integers in base n

Have same notion of position and digits

digits: {0, 1, ... n-1} positions: powers of n 1342 in base 6 = 1*63 + 3*62 + 4*61 + 2*60 10101 in base 2 (binary) = 1*24 + 0*23 + 1*22 + 0*21 + 1*20

¡

Example:

¡

Positions are powers of 10, digits are {0, 1, ..., 9}

¡

**Converting from base n to decimal
**

Multiply digits by positions in the base n number, as on the previous slide Examples:

1342 in base 6 = 1*63 + 3*62 + 4*61 + 2*60 = 350 in base 10 10101 in base 2 (binary) = 1*24 + 0*23 + 1*22 + 0*21 + 1*20 = 21 in base 10 00100101 in binary = 1*25 + 1*22 + 1 = 37 in base 10

£ ¢ ¢

**Converting from decimal to base n
**

Divide the decimal number repeatedly by the base

idea: find the largest power of n that fits into that decimal number at each stage, the remainder becomes the leftmost digit carry the quotient to the next stage repeat until the quotient is zero

£ £ £ £

¢

**Converting from decimal to base n: examples
**

543 to base 5:

543/5 = 108 rem 3 108/5 = 21 rem 3 21/5 = 4 rem 1 4/5 = 0 rem 4 = 4133

£ £ ¢

£

£

Example cont.

982 from decimal to binary:

982/2 = 491 rem 0 491/2 = 245 rem 1 245/2 = 122 rem 1 122/2 = 61 rem 0 61/2 = 30 rem 1 30/2 = 15 rem 0 15/2 = 7 rem 1 7/2 = 3 rem 1 3/2 = 1 rem 1 1/2 = 0 rem 1

¤ ¤ ¤ ¤ ¤ ¤ ¤ ¤ ¤ ¤ ¢

982 to binary = ?

¢

£

£

£

= 1111010110

¥

**Representing negative numbers in binary
**

One approach: signed-magnitude

for an 8-bit number, the first bit is the sign (0=positive, 1=negative), and the other 7 bits are the value

can represent all numbers from -127 to 127 1 = 00000001, -1 = 10000001 65 = 01000001, -65 = 11000001 0 = 00000000, -0 = 10000000 --> problem!

¦ ¨ § ¦ ¦ ¦

**Another way to represent negative numbers: two's complement
**

Allows us to represent negative numbers in binary, without the “two zeros” problem All positive numbers start with a 0, as before Negative numbers:

Invert all the bits (change 0's to 1's and 1's to 0's) Add 1 to this number

§ §

examples:

¨ ¨

§

¦

**With 8 bits, can represent all numbers from -128 to 127
**

one extra than with signed-magnitude

§

**More two's complement examples
**

-7:

7 is 00000111 invert bits: 11111000 add 1: 11111001 127 is 01111111 invert bits: 10000000 add 1: 10000001

¦ ¦ § § ¦ ¦

¨

Scientific notation

Expressing very large or very small numbers can be tedious

e.g., 2147483647, 0.245689734921

-127:

§ §

**Scientific notation allows us to express large or small numbers more compactly
**

show us the “order of magnitude” of the number, rather than all of the digits

§

¦

§

Format: mantissa x 10exponent

-1: 00000001 -> 11111110 -> 11111111

¦

§

§

Examples

2147483647 = 2.147 x 109 0.245689734921 = 2.457 x 10-1 0.0000000000000567 = 5.67 x 10-14

© © © ©

**Representing real numbers in binary
**

Use scientific notation: a x 2N a and N are both binary Format: (IEEE 754 32-bit standard)

1 bit for the sign 8 bits for the exponent (N) 23 bits for the mantissa (a)

©

©

**Converting decimal (fractional) number to binary
**

Multiply fractional part by 2 Integer part of the answer becomes the next rightmost digit in the number Carry the fractional part to the next step Repeat until the fractional result of multiplication is 0, or until the desired precision is reached

© ©

Example

Convert 0.25 to binary:

0.25*2 = 0.5 0.5 * 2 = 1.0 = 0.01 * 20 step 1: convert 10 to binary --> 1010 step 2: convert .125 to binary:

0.125*2 = 0.250; 0.250*2 = 0.5; 0.5*2 = 1.0 = 0.001 = -1010.001 * 20 = -0.1010001 * 24

© ©

Convert -10.125 to binary:

©

©

step 3: put them together

**Previous examples, in IEEE 794 format
**

0.25 = 0.01 * 20 = 00000000001000000000000000000000 -10.125 = -0.1010001 * 24 = 10000010010100010000000000000000

- GT an Toan Va Bao Mat Thong Tin
- lab1
- lab1
- Help Google Apps
- Phương pháp Token Bus
- Token Ring Va FDDI
- Info
- Chan Dung Nha Lanh Dao
- Cau hoi on tap KTCT Mac-Lenin
- 6906241-mau-ktth
- Java Ly thuyet
- nganhang
- Benh sung nhiep ho tuyen2
- Benh sung nhiep ho tuyen1
- Storage Vietnamese P&T
- Quan tri mang
- giao trinh mang v10
- bai giang OSI-TCP
- Bai giang IP
- ICP IP new
- IP Subnet Calculations
- He nhi phan
- giao trinh mang may tinh
- cai dat mang

- numbers
- Number Systems (1)
- Application of Gray Code
- Lab_1_5_9
- Unit 2- Binary Numbers and Arithmetic
- The Power of Binary
- Joy
- Decimal to Binary(by me)
- Binary System
- Number System 1
- Student Binary
- 3-Presentations COE 081 202 Number Systems Operations and Codes
- Synopsis of DE 202
- The Binary System
- BINARY-CODED DECIMAL in Today’s Technology, You Hear a Great Deal
- Number Systems
- Lecture_3_numbersystem_.pdf
- Lecture 03
- Binary Numbers
- Adding Binary Numbers
- Adding Binary Numbers
- Unit 3
- Binary Nos1
- mca material
- Binary
- Binary to Decimal
- bk9_1
- Untitled
- Binary Numbers
- Unit 1 Number Systems
- ICP IP

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd