1 / 20

EMK 310

EMK 310. Numbering systems and floating point operations (Bolton, Sections 1.3 – 1.6). 1.3.1 Binary system. All microcontrollers / processors operate on Binary System. Binary = two states ‘1’ = High voltage input ( TTL : 2 – 5V CMOS: 3.5 – 5V)

magar
Download Presentation

EMK 310

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EMK 310 Numbering systems and floating point operations (Bolton, Sections 1.3 – 1.6)

  2. 1.3.1 Binary system • All microcontrollers / processors operate on Binary System. • Binary = two states • ‘1’ = High voltage input ( TTL : 2 – 5V CMOS: 3.5 – 5V) • ‘0’ = Low voltage input ( TTL : 0 – 0.8V CMOS: 0 – 0.5 V)

  3. 1.3.1 Binary system • Just as with the decimal system each bit represents the radix to the power of its position: • I.e.: 100012 = 1x20 + 0x21 + 0x22 + 0x23 +1x24 • Basic concepts: • Least significant bits (LSB) rightmost (smallest) bits. • Most significant bits (MSB) leftmost (largest) bits.

  4. 1.3.1 Binary systems • Conversions: • Decimal to binary: • Use decimal number and divide by two until the result is equal to ‘1’, use the remainder of each computation as the binary bit representation from the MSB to the LSB.

  5. 1.3.1 Binary system • Example: 1000102

  6. 1.3.1 Binary systems • Conversions: • Decimal fractions to binary fractions: • Convert the integer part of the decimal number to binary. • Multiply the decimal fractions repetitively by a factor of ‘2’, the integer part is the 2-1 digit and the fraction is further multiplied by a factor of 2 to produce 2-2. This pattern is repeated until the fractional part = ‘0’ or you are satisfied with you resolution. • E.g.: 0.675 = 0.101011

  7. 1.4 Binary arithmetic • Addition: same as with decimal addition! Start adding at the LSB! E.g.: 1101102 + 1011112 = 10001012

  8. 1.4 Binary arithmetic • Subtraction: same as with decimal subtraction! Start subtracting at the LSB! E.g.: 1101102 - 1011112 = 0001112

  9. 1.4 Binary arithmetic • Negative numbers: • Two’s compliment is used to represent negative numbers. • Firstly exclusive or the binary number with ‘1’ • Add ‘1’ to the complimented number. • E.g.: -10: 10 = 010102 -> 101012 + 12 = 101102

  10. 1.4 Binary arithmetic • Subtraction: 2nd method is to perform two’s compliment and then add the two numbers. E.g.: 01101102 (54) + 10100012 (-47) = 00001112 (7)

  11. 1.3.2 Octal system • Just as with all other number systems each position represents the radix to the power of its position times the number in that slot: • I.e.: 1278 = 7x80 + 2x81 + 1x82 • Conversions: • Decimal to octal: • Use decimal number and divide by ‘8’ until the result is equal to or smaller than ‘7’, use the remainder of each computation as the octal representation from the MSB to the LSB.

  12. 1.3.2 Octal system • Example: 428

  13. 1.3.2 Octal system • Conversions: • Decimal fractions to octal fractions: • Convert the integer part of the decimal number to octal. • Multiply the decimal fractions repetitively by a factor of ‘8’, the integer part is the 8-1 digit and the fraction is further multiplied by a factor of 8 to produce 8-2. This pattern is repeated until the fractional part = ‘0’ or you are happy with you resolution. • E.g.: 0.52 = 0.412

  14. 1.3.3 Hexadecimal system • Just as with all other number systems each position represents the radix to the power of its position times the number in that slot: • I.e.: 1A716 = 7x160 + 10x161 + 7x162 • Conversions: • Decimal to hexadecimal: • Use decimal number and divide by ‘16’ until the result is equal to or smaller than ‘15’, use the remainder of each computation as the octal representation from the MSB to the LSB. Where A=10, B=11, C=12, D=13, E=14, F=15

  15. 1.3.3 Hexadecimal system • Example: 2216

  16. 1.3.3 Hexadecimal system • Conversions: • Binary to hexadecimal: • Pairs of 4 binary digits can always be grouped and used to convert the binary code to hexadecimal and vice versa. • E.g.: 1001 1111 1100 00012 = 9 F C 116

  17. 1.3.3 Hexadecimal system • Conversions: • Decimal fractions to hexadecimal fractions: • Convert the integer part of the decimal number to octal. • Multiply the decimal fractions repetitively by a factor of ‘16’, the integer part is the 16-1 digit and the fraction is further multiplied by a factor of 16 to produce 16-2. This pattern is repeated until the fractional part = ‘0’ or you are happy with you resolution.

  18. 1.3.4 Binary coded decimal • The binary code is generated, such that the hexadecimal number looks like a decimal number. I.e.: Instead of A = 1010 binary coded decimal will represent A as 10 = 0001 0000. • See table 1.1 in Bolton 4 more details

  19. 1.5.1 Floating point arithmetic • When performing calculations with floating point numbers. E.g. 1.6e32. You have to make sure that you perform all computations with respect to the same decimal digit. • 1.6e32 + 230e34 = 1.6e32+2.3e32 = 3.9e32

  20. 1.6 ASCII codes • When communication with other peripherals ASCII codes are often used. Each ASCII character has a specific hexadecimal code which is then transmitted. See table 1.3 for important control characters.

More Related