positional notation of unsigned integers
play

Positional notation of unsigned integers The base - b positional - PDF document


  1. ��������������������� �������� ���������������� ������ ����������������� ������ ���������������� 02 Information theory 02.02 Binary arithmetic • Positional notation • Unsigned integers • Unsigned fixed-point • Signed numbers • Floating point numbers • Base conversions • Binary arithmetic ���������� �������� ���� �������������������������������������������� � ��� ��������������������� �������� ���������������� ������ ����������������� ������ ���������������� Positional notation of unsigned integers • The base - b positional representation of an integer number of n digits has the form c c ... c c (1) n − 1 n − 2 1 0 • The value of the number is n − 1 n − 2 1 0 (2) c b c b ... c b c b + + + + n 1 n 2 1 0 − − • n digits encode all integer numbers from 0 to b n -1 Example: b =2, n =5 10011=1*16+1*2+1*1=19 11111=31=2 5 -1 ���������� �������� ���� �������������������������������������������� � ��� 1

  2. ��������������������� �������� ���������������� ������ ����������������� ������ ���������������� Base conversion • From base b to decimal: n − 1 n − 2 1 0 (2) c b + c b + ... + c b + c b n − 1 n − 2 1 0 • From decimal to base b : digits from c 0 to c n- 1 are obtained as remainders of subsequent divisions by b of the digital number n − 1 n − 2 1 0 (3) c b + c b + ... + c b + c b = n − 1 n − 2 1 0 n − 2 n − 3 0 = ( c b + c b + ... + c b ) b + c n − 1 n − 2 1 0 ���������� �������� ���� �������������������������������������������� � ��� ��������������������� �������� ���������������� ������ ����������������� ������ ���������������� Base conversion example (29) (10) =(11101) (2) (11001) (2) =(25) (10) position weight digit 29 0 1 1 1 + 29 14 1 29=14*2+ 1 1 0 2 0 + 14 7 0 14=7*2+ 0 2 0 4 0 + 7 3 1 7=3*2+ 1 3 1 8 8 + 3 1 1 3=1*2+ 1 4 1 16 16 1=0*2+ 1 1 0 1 25 ���������� �������� ���� �������������������������������������������� � ��� 2

  3. ��������������������� �������� ���������������� ������ ����������������� ������ ���������������� Fixed-point notation of unsigned rational numbers • The base - b positional representation of a rational number of n+m digits has the form c c ... c c . c ... c (4) n − 1 n − 2 1 0 − 1 − m • The value of the number is n − 1 n − 2 1 0 − 1 − m (5) c b + c b + ... + c b + c b + c b + ... + c b n − 1 n − 2 1 0 − 1 − m • n+m digits encode all rational numbers of the form Num (6) m 2 with n + m 0 ≤ Num ≤ 2 − 1 ���������� �������� ���� �������������������������������������������� � ��� ��������������������� �������� ���������������� ������ ����������������� ������ ���������������� Base conversion • From base b to decimal: n − 1 n − 2 1 0 − 1 − m c b + c b + ... + c b + c b + c b + ... + c b (5) n − 1 n − 2 1 0 − 1 − m • From decimal to base b : – Solution 1: Given a digital number X=Num /2 m , convert Num and shift the decimal point m positions left – Solution 2: Given a digital number X = X int . X frac , convert the integer part X int as outlined before, then convert the fractional part X frac obtaining each digit as the integer part of the result of subsequent multiplications by b : − 1 − 2 − m − 1 − m − 1 (7) ( c b + c b ... + c b ) b = c + c b ... + c b − 1 − 2 − m − 1 − 2 − m ���������� �������� ���� �������������������������������������������� � ��� 3

  4. ��������������������� �������� ���������������� ������ ����������������� ������ ���������������� Base conversion example (29.375) (10) =(11101.011) (2) 29 0.375 *2 = 0.75 = 0 + 0.75 29 14 1 29=14*2+ 1 0.75 *2 = 1.5 = 1 + 0.5 14 7 0 14=7*2+ 0 7 3 1 7=3*2+ 1 0.5 *2 = 1 = 1 + 0 3 1 1 3=1*2+ 1 1 0 1=0*2+ 1 1 ���������� �������� ���� �������������������������������������������� � ��� ��������������������� �������� ���������������� ������ ����������������� ������ ���������������� Binary arithmetics • Binary addition: 1 1 1 1 0 1 1 5 0 1 1 1 1 0 0 1 6 0 0 1 1 0 1 1 10 2 1 1 0 1 0 1 • Binary multiplication: 1 0 1 1 1 0 0 1 2 0 0 0 1 1 0 1 1 3 1 0 1 1 1 0 0 3 6 0 0 0 0 - 2 - 1 1 1 0 0 - - 1 5 6 1 1 0 0 - - - 1 0 0 1 1 1 0 0 ���������� �������� ���� �������������������������������������������� � ��� 4

  5. ��������������������� �������� ���������������� ������ ����������������� ������ ���������������� Signed numbers • Sign bit: 0=positive, 1=negative (3) (10) = 0 0011; (-3) (10) = 1 0011 • 1’s complement (3) (10) = 0 0011; (-3) (10) = 1 1100 = (0 0011) ’ • 2’s complement (3) (10) = 0 0011; (-3) (10) = 1 1101 = (0 0011) ’ +1 ���������� �������� ���� �������������������������������������������� � ��� ��������������������� �������� ���������������� ������ ����������������� ������ ���������������� 2’s complement numbers • The 2 ’ s complement representation of a negative number (say, - v ) is obtained from the representation of v, by complementing each bit (including the sign bit) and adding 1 - v � v ’ +1 • The resulting binary configuration corresponds to the unsigned number 2 n - v (i.e. , the complement of v to 2 n ), where n is the total number of digits, including the sign 2 n bit. 2 n -v 0 v -v negative positive ���������� �������� ���� �������������������������������������������� �� ��� 5

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend