Download presentation
Published byBenjamin Ward Modified over 9 years ago
1
Number Systems Denary Base 10 Binary Base 2 Hexadecimal Base 16
Conversion between number systems. Signed numbers, 2’s complements binary and binary fractions. Floating point formats. Simple arithmetic operations using binary number. Bits, bytes and words
2
Denary Base 10 The base-10 system (decimal) is the most commonly used today ( ) To represent the number four thousand three hundred and twenty one (4321) Thousand Hundreds Tens Units 103 102 101 100 1000 10 1 4×1000 3×100 2×10 1×1 4000 +300 +20 Total 4321
3
Binary Base 2 The base-2 system (Binary) the binary system is used internally by virtually all modern computers. ( ‘0’ or ‘1’ ) 1 27 26 25 24 23 22 21 20 127 64 32 16 8 4 2 0×127 1×64 0×32 1×16 1×8 1×4 0×2 1×1 +64 +0 +16 +8 +4 +1 Total 93
4
Hexadecimal Base 16 The base-16 system (Hexadecimal) uses the numerals “ B C D E F” Easy to represent binary code (form of shorthand) in which one hexadecimal digit stands in place of four binary bits. F A 161 160 16 1 15×16 10×1 240 +10 Total Hex f a Binary ,
5
Converting from denary to binary
1) Start with the number you want (44) 2) Divide by the base you want to convert to (2) 3) Calculate the remainder from the sum 4) Place result of the sum on the next row Number Base required Remainder 44 ÷ 2 22 11 1 5 44 denary = binary
6
Converting from denary to hex
1) Start with the number you want (4321) 2) Divide by the base you want to convert to (16) 3) Calculate the remainder from the sum 4) Place result of the sum on the next row Number Base required Remainder 4321 ÷ 16 1 270 E (14) 4321 Denary = 10E1 Hexadecimal
7
Denary, Hex & Binary Denary Hex Binary 1 2 3 4 5 6 7 8 9 10 A 11 B 12
1 2 3 4 5 6 7 8 9 10 A 11 B 12 C 13 D 14 E 15 F
8
Signed numbers In mathematics negative numbers can be prefixed by the '-' symbol. On a computer system several methods cane be used Use of a sign bit Often Most Significant bit is used for the sign Number Binary 7 1 -0 -7 4 Bits gives a range -7 to +7 Two representations of '0'
9
1's complement To obtain the negative number the positive binary value is complemented '0' replaced with '1' and '1' replaced with '0' For example binary (decimal 10) complemented becomes
10
2's complement To obtain the 2's complement of a number
First the 1's complement is obtained Then 1 is added i.e. decimal 10 = , complemented = add 1 = Advantage of 2's complement is that no separate addition and subtraction circuits are required
11
Binary fractions So far only integer numbers have been considered
Whole Number Fraction 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 sign 26 25 24 23 22 21 20 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 Decimal would be Limited by the number of bits assigned to whole number Accuracy is lost smallest value is
12
Floating point numbers
In scientific applications we often need very small or large numbers In the floating point system number is represented by a signed fractional component called the mantissa and a signed exponent. mantissa × 10exponent The value is normalised i.e would be become 0.123×107 In a typical system where a float is 32 bits 24 bits hold the signed mantissa and 8bits for the exponent Floating point calculations often carried out in a separate co processor
13
Binary arithmetic Binary addition Dec Binary 10 1 +9 19 A op B Sum
Carry + 1 Dec Binary 10 1 +9 19
14
Binary arithmetic Binary subtraction A op B Sum borrow - 1
- 1 * * * * (starred columns are borrowed from) − =
15
Binary arithmetic Multiplication - Two numbers A and B can be multiplied by partial products: for each digit in B, the product of that digit in A is calculated and written on a new line, shifted leftward so that its rightmost digit lines up with the digit in B that was used. The sum of all these partial products gives the final result. (A) (decimal 11) × (B) (decimal 10) ← Corresponds to a zero in B ← Corresponds to a one in B = (decimal 110)
16
Binary arithmetic Division i.e. divide 0110101 (53) by 0101 (5).
___ (10 answer) 0101| 0101 110 11 (3 remainder)
17
Bits Bytes & Words Bit either a '1' or a '0'
Byte comprises 8 bits ' ' Nibble - Half a byte (4 bits) '1011' Word Normally the bus width of the microprocessor – in this case 32 bits Hex numbers in the keil compiler are prefixed by '0x' (0xa7) Floating point numbers – exponent is represented by the letter 'e' (1.25e-3)
18
ASCII character codes Integer numbers are easily represented in binary. This is not the case for characters and other punctuation marks. The standard ASCII code defines 128 character codes (from 0 to 127), of which, the first 32 are control codes (non-printable), and the other 96 are represent printable characters. The ASCII code requires a 7 bit binary code. Memory is usually a 8-bit wide which leaves 1 unused bit – use to provide additional characters called Extended ASCII. Not standardised!
19
The Standard ASCII Table
* 1 2 3 4 5 6 7 8 9 A B C D E F NUL SOH STX ETX EOT ENQ ACK BEL BS TAB LF VT FF CR SO SI DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US ! " # $ % & ' ( ) + , - . / : ; < = > ? @ G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ * This table is organized to be easily read in hexadecimal: row numbers represent the first digit and the column numbers represent the second one. For example, the A character is located at the 4throw and the 1st column, for that it would be represented in hexadecimal as 0x41 (6510).
20
Unicode ASCII only supports 128 characters
ASCII was extended to 255 characters using the iso 8859 method, where 15 regions/language groups were defined. Unicode method contains all the worlds characters (well almost) in one coding list. Uses multibyte encoding of 1,2 or 4 bytes Common coding is UTF-8 first 128 codes same as ASCII so provides backwards compatibility See
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.