Sistem Bilangan

Embed Size (px)

Citation preview

  • Sistem BilanganOleh :Moch Nur Purnama

  • Analogue vs DigitalAnalogue* Continuous range of value* Precision limited by Noise Digital* Discrete range of values * Precision limited by number of Bit

  • Analogue vs DigitalAnalogueDigital

  • Analogue vs DigitalThe 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

  • Analoge vs DigitalAnalogueA to DDigital ProcessingD to AAnalogueWhy 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

  • Digital and BooleanDigital represented by boolean logicBoolean is the name of mathematicians expert Now boolean is called by conventional logic because there is new logic that called by fuzzy logicBut all electronic still using boolean logic to processing the controlling system

  • Why BooleanIt 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)* Dont 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

  • Positional Number System3578.7788x10-3

    8 x 1007 x 1015 x 1023 x 1037x10-27x10-1Decimal pointBase 10, weigthing are powers of 10

  • Unsigned binary numbers1100.1011 x 2-3 = 0.125

    0 x 20= 0.0000 x 21= 0.0001 x 22= 4.0001 x 23= 8.0000 x 2-2 = 0.0001 x 2-1 = 0.500Binary pointEach bit of the Number may beRepresentaed byA Boolean valueBinary, weightings are powers of 2

  • Multi-precision ArithmaticAdditional of A and B

  • Multi-precision ArithmaticA1B1A2B2-B3Carry FlagA2Carry OutCarry In

  • Hexadecimal Numbers660: 16441: 1692Hexadecimal : 294 Hex01234567891011121314150123456789ABCDEF215: 16137Hexadecimal : 7D Hex

  • Hexadecimal Numbers6600010 1001 01000123456789ABCDEF0000000100100011010001010110011110001001101010111100110111101111 2 9 4215 0000 1101 0111 0 D 7

  • Decimal to BinaryGeneretee each digit by successive division Or multiplication.

    There is no guarantee the fraction will be finite Fractional part Multiplication by baseWhole part divition by base

    Number =36.375Base =2

    Decimal NumberBinary DigitsConverter Number000100100.01100.510100100.0110.7510100100.010.37500100100.036001001001800100109101001400100200101101000

  • Binary Additional0 + 0 = 00 + 1 = 11 + 0 = 11 + 1 = 0 carry 1Easy Layaou ?

  • Binary Addition190 + 141 =3311 0 1 1 1 1 1 01 0 0 0 1 1 0 11101110101101Carry out of8-bit number1Carry out ofEach column

  • Binary Subtraction229 46 = 1831 1 1 0 0 1 0 10 0 1 0 1 1 1 0112112101212112101Borrow outBorrow in fromLeft columnA borrow-out of 1 fromThis column becomes a borrow in of 2 in this columnBoth rows subtracted

  • ExerciseConvert 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

  • Binary Number Circle4 bitBinaryNumber CircleIn 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 aroundAt 15 0

    11 - 1 = 1011 1110- 1 110 1010

  • Binary Number Circle4 bitBinaryNumber CircleSubtracting across the boundaryStill works if you think of result As the distance on the number Circle. (Module arithmetic ignoreThe borrow /carry) 8 1000- 14 - 111010 (-1)1010

  • Representing ve NumberSeveral choices for natation* sign + magnitude notation* 1s complement* 2s complement notation* various excess codes

  • Sign Number sign + magnitude Notation Sign Bit Magnitude0 +veSimple binary number1 - ve Problem ?How about Null or Zero + 0 0000 - 0 1000

  • Signed Numbers Sign + magnitude NotationArithmeticDifficult to do have to work out that operation to perform5 + -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!

  • Sign + Magnitude Examples

    Value4-bit sign + magnitude8-bit sign + magnitude+7011100000111+6011000000110+1000100000001+0000000000000-0100010000000-1100110000001-2101010000010-7111110000111

  • Sign Numbers 2s ComplementAs for straight binary numbers but with the weighting of the most significant bit being negativeExample* 4 bit weights are -8, 4,2,1* 8 bit weights are -128, 64,32,16,8,4,2,1Need to know how many bits are being used to work out the value of the number dont omit leading zeroes

  • Sign Numbers 2s Complement1100.1011 x 2-3 = 0.125

    0 x 20= 0.0000 x 21= 0.0001 x 22= 4.0001 x 23= -8.0000 x 2-2 = 0.0001 x 2-1 = 0.500Binary pointSign BitBinary, weightings are powers of 2 -4.375

  • 2s Complement Examples

    Value4-bit sign 2s complement 8-bit sign complement+7011100000111+6011000000110+1000100000001+0000000000000-1111111111111-2111011111110-7100111111001-8100011111000

  • 2s Complement ExamplesExample : -4 (decimal)

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

  • ExerciseConverse decimal number above into negative (2s complement) :-7 ( 4 digit ) 6. 6 (4 digit) -7 (8 digit)7. 10 (8 digit)-12 (8 digit)8. 30 (8 digit)-20 (8 digit)9. 98 (digit)-100 (8 digit) 10. 126 (digit)

  • Addition 2s ComplementFor 4 digit : 4 0100 3 + 0011 + 7 0111 22+21+20 = 4+2+1 =7

  • Addition 2s ComplementFor 4 digit -1 1111 -2 + 1110 + -3 11101-(8)+4 +0 + 1 = -3 Carry out

  • ExerciseFor 4 Digit : 7 + (-5)-6 + -13 + 42 + 3-4 + 7Converse all item to digital and addition. And then Converse to decimal again

  • Subtraction 2s Complement

    + 7 0111 + 3 (0011)- 1101 + +4 10100 Discard

  • Subtraction 2s Complement

    (-8) 1000 (-3) = 1101 - 0011 + -5 1011

  • Exercise for 4 digit . Converse decimal above to digit and subtraction. After that converse to decimal again :(+3) (-3)(-4) (+2)(-8)- (+4)(-3) (-4)(7) (5)

  • 2s Complement ALUAddition 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=CarryV=overflowOPSigned NumbersSigned NumbersThe samehardwareArithmetic Flags in Condition code register (CCR)