36
Sistem Bilangan Oleh : Moch Nur Purnama

Sistem bilangan

Embed Size (px)

DESCRIPTION

Kimia

Citation preview

Page 1: Sistem bilangan

Sistem Bilangan

Oleh :

Moch Nur Purnama

Page 2: Sistem bilangan

Analogue vs Digital

Analogue

* Continuous range of value

* Precision limited by Noise Digital

* Discrete range of values

* Precision limited by number of “Bit”

Page 3: Sistem bilangan

Analogue vs Digital

Analogue Digital

Page 4: Sistem bilangan

Analogue vs Digital

The real world is analogue ( by because all signal in world be shape analogue)

But in controlling, Digital one had using for process.

Both of signal had been converter each other

Page 5: Sistem bilangan

Analoge vs Digital

Analogue A to DDigital

ProcessingD to A Analogue

Why Digital Only by using in Processing?

^ Adventure in integrated Circuit has made the complex processing of digital data. ^ Digital Control processing has made easier than analogue^ Digital circuits are inherently more noise resistant

Page 6: Sistem bilangan

Digital and Boolean

Digital represented by boolean logicBoolean is the name of mathematician’s

expert Now boolean is called by conventional

logic because there is new logic that called by fuzzy logic

But all electronic still using boolean logic to processing the controlling system

Page 7: Sistem bilangan

Why Boolean

It is convenient in electrical system to use a two-value system to represent value true/false, on/off, yes/no and 1/0* Two voltage or current levels can be used* Easier to process and distribute reliably (diandalakan)* Don’t think of them as numbers (even though we often represent them as 0/1 for brevity(ketangkasan))

The need for binary numbers* Multi-value quantities need to be represented in the digital system. Therefore need numbers made up from the simple two value system

Page 8: Sistem bilangan

Positional Number System

3578.778

8x10-3

8 x 100

7 x 101

5 x 102

3 x 103

7x10-2

7x10-1Decimal point

Base 10, weigthing are powers of 10

Page 9: Sistem bilangan

Unsigned binary numbers

1100.101

1 x 2-3 = 0.125

0 x 20= 0.0000 x 21= 0.0001 x 22= 4.0001 x 23= 8.000

0 x 2-2 = 0.000

1 x 2-1 = 0.500Binary point

Each bit of the Number may beRepresentaed byA Boolean value

Binary, weightings are powers of 2

Page 10: Sistem bilangan

Multi-precision Arithmatic

Additional of A and B

A1 B1

A2 B2

+

B3

Carry Flag

Carry Flag

A2

Carry Out

Carry In

Carry Out

Page 11: Sistem bilangan

Multi-precision Arithmatic

A1 B1

A2 B2

-

B3

Carry Flag

A2

Carry Out

Carry In

Page 12: Sistem bilangan

Hexadecimal Numbers

660: 164

41: 169

2

Hexadecimal : 294 Hex

0123456789101112131415

0123456789ABCDEF

215: 1613

7

Hexadecimal : 7D Hex

Page 13: Sistem bilangan

Hexadecimal Numbers

660 0010 1001 01000123456789ABCDEF

0000000100100011010001010110011110001001101010111100110111101111

2 9 4

215 0000 1101 0111

0 D 7

Page 14: Sistem bilangan

Decimal to Binary

Number = 36.375

Base = 2

Decimal Number

Binary Digits

Converter Number

0 0 0100100.0110

0.5 1 0100100.011

0.75 1 0100100.01

0.375 0 0100100.0

36 0 0100100

18 0 010010

9 1 01001

4 0 0100

2 0 010

1 1 01

0 0 0

Generetee each digit by successive division Or multiplication.

There is no guarantee the fraction will be finite

Fractional part – Multiplication by base

Whole part – divition by base

Page 15: Sistem bilangan

Binary Additional

0 + 0 = 0

0 + 1 = 1

1 + 0 = 1

1 + 1 = 0 carry 1

Easy Layaou ?

Page 16: Sistem bilangan

Binary Addition

190 + 141 =331

1 0 1 1 1 1 1 01 0 0 0 1 1 0 1

110

1

1

1

0

1

0

1

101

Carry out of8-bit number

1

Carry out ofEach column

Page 17: Sistem bilangan

Binary Subtraction

229 – 46 = 183

1 1 1 0 0 1 0 1

0 0 1 0 1 1 1 0

1

1

2

1

1

2

10

1

2

1

2

1

1

2

101 Borrow out

Borrow in fromLeft column

A borrow-out of 1 fromThis column becomes a borrow in of 2 in this column

Both rows subtracted

Page 18: Sistem bilangan

Exercise

Convert to 8-bit binary and do the arithmetic operation

* 120 + 54 * 110 + 100

* 224 – 134 * 200 + 20

* 112 – 89 * 111 – 25 Convert back to decimal and check the

result

Page 19: Sistem bilangan

Binary Number Circle

4 – bitBinary

Number Circle

In real hardware there is a fixed numberOf bits available. We often ignore leading zerosBut they are still there!

Examlpe :If we only use 4 bits then the binaryCounting sequence “wraps around”At 15 ↔ 0

11 - 1 = 10

11 1110- 1 1

10 1010

Page 20: Sistem bilangan

Binary Number Circle

4 – bitBinary

Number Circle

Subtracting across the boundaryStill “works” if you think of result As the distance on the number Circle.

(Module arithmetic – ignoreThe borrow /carry)

8 1000- 14 - 1110

10 (-1)1010

Page 21: Sistem bilangan

Representing –ve Number

Several choices for natation

* sign + magnitude notation

* 1’s complement

* 2’s complement notation

* various ‘excess codes ‘

Page 22: Sistem bilangan

Sign Number – sign + magnitude Notation

Sign Bit Magnitude

0 +ve Simple binary number

1 - ve

Problem ?

How about Null or Zero

+ 0 0000 - 0 1000

Page 23: Sistem bilangan

Signed Numbers – Sign + magnitude Notation

Arithmetic Difficult to do – have to work out that operation to

perform 5 + -6 actually calculate –(6-5) i.e. exchange the

operands and do subtraction! -5+ -6 actually calculate –(5+6) i.e. negate the addition

of the negated numbers ! Required action depends the signs of the numbers

and on which has the large magnitude. Natural for us –a bit hard for the computer since the only way it can work out the bigger number is to do a subtraction!

Page 24: Sistem bilangan

Sign + Magnitude Examples

Value4-bit sign + magnitude

8-bit sign + magnitude

+7 0111 00000111

+6 0110 00000110

…… …… ……

+1 0001 00000001

+0 0000 00000000

-0 1000 10000000

-1 1001 10000001

-2 1010 10000010

…… …… ……

-7 1111 10000111

Page 25: Sistem bilangan

Sign Numbers – 2’s Complement

As for straight binary numbers but with the weighting of the most significant bit being negative

Example

* 4 bit – weights are -8, 4,2,1

* 8 bit – weights are -128, 64,32,16,8,4,2,1 Need to know how many bits are being used

to work out the value of the number – don’t omit leading zeroes

Page 26: Sistem bilangan

Sign Numbers – 2’s Complement

1100.101

1 x 2-3 = 0.125

0 x 20= 0.0000 x 21= 0.0001 x 22= 4.0001 x 23= -8.000

0 x 2-2 = 0.000

1 x 2-1 = 0.500Binary point

Sign Bit

Binary, weightings are powers of 2 -4.375

Page 27: Sistem bilangan

2’s Complement Examples

Value4-bit sign 2’s complement

8-bit sign complement

+7 0111 00000111

+6 0110 00000110

…… …… ……

+1 0001 00000001

+0 0000 00000000

-1 1111 11111111

-2 1110 11111110

…… …… ……

-7 1001 11111001

-8 1000 11111000

Page 28: Sistem bilangan

2’s Complement Examples

Example : -4 (decimal)

Become 4 = 0100 ( binary) = 1x22 = 42’s Complement -4= 1100 (binary) = -(23) + 22

= -8 + 4 = -4

Page 29: Sistem bilangan

Exercise

Converse decimal number above into negative (2’s complement) :

1. -7 ( 4 digit ) 6. 6 (4 digit)

2. -7 (8 digit) 7. 10 (8 digit)

3. -12 (8 digit) 8. 30 (8 digit)

4. -20 (8 digit) 9. 98 (digit)

5. -100 (8 digit) 10. 126 (digit)

Page 30: Sistem bilangan

Addition 2’s Complement

For 4 digit :

4 0100

3 + 0011 +

7 0111

22+21+20 = 4+2+1 =7

Page 31: Sistem bilangan

Addition 2’s Complement

For 4 digit

-1 1111

-2 + 1110 +

-3 11101

-(8)+4 +0 + 1 = -3 Carry out

Page 32: Sistem bilangan

Exercise

For 4 Digit : 1. 7 + (-5)2. -6 + -13. 3 + 44. 2 + 35. -4 + 7Converse all item to digital and addition.

And then Converse to decimal again

Page 33: Sistem bilangan

Subtraction 2’s Complement

+ 7 0111

+ 3 (0011)- 1101 +

+4 10100

Discard

Page 34: Sistem bilangan

Subtraction 2’s Complement

(-8) 1000

(-3) = 1101 - 0011 +

-5 1011

Page 35: Sistem bilangan

Exercise

for 4 digit . Converse decimal above to digit and subtraction. After that converse to decimal again :

1. (+3) – (-3)2. (-4) – (+2)3. (-8)- (+4)4. (-3) – (-4)5. (7) – (5)

Page 36: Sistem bilangan

2’s Complement ALU

Addition and subtraction use the same rules as unsigned binary.

Same hardware may be used for both Carry (C) is used for unsigned, overflow (v) for signed

C=Carry

V=overflow

OP

Signed Numbers

Signed Numbers

C=Carry

V=overflow

OP

Signed Numbers

Signed Numbers

The samehardware

Arithmetic Flags in Condition code register (CCR)