0% found this document useful (0 votes)
13 views

Proprep - Principles of Programming - Chapter 1 - Machine Level Representation of Data - Workbook Uk

Uploaded by

julia.g24kamil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Proprep - Principles of Programming - Chapter 1 - Machine Level Representation of Data - Workbook Uk

Uploaded by

julia.g24kamil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Principles of Programming

Table of Contents

Machine level representation of data ...............................................................................2


Numeric data and number bases ............................................................................ 2
Signed and twos complement ................................................................................. 4
Fixed and floating point ............................................................................................ 6

For more information and all the solutions, please go to www.proprep.uk


For any questions please contact us at +44-161-850-4375 or [email protected]
1
© All rights in this workbook reserved to proprep™
Principles of Programming

Machine level representation


of data

Numeric data and number bases


Questions
Convert the following numbers from binary to decimal:
a. (1011001)2
b. (110110101)2

Convert the following numbers from decimal to binary:


a. (237)10
b. (359)10
c. (1857)10
d. (44100)10

Convert the following numbers from hexadecimal to binary:


a. (42)16
b. (D9)16
c. (1FA)16
d. (CDDB)16

Convert the following from decimal to hexadecimal:


a. (240)10
b. (251)10
c. (1100)10
d. (25432)10
e. (112000)10

In what situation might:


a. binary representation be useful to a programmer?
b. hexadecimal representation be useful to a programmer?

Of the numbers (55)10, (37)16 and (67)8 which is the largest?

For more information and all the solutions, please go to www.proprep.uk


For any questions please contact us at +44-161-850-4375 or [email protected]
2
© All rights in this workbook reserved to proprep™
Principles of Programming

Answer Key
a. (89)10 b. (437)10
a. (11101101)2 b. (101100111)2 c. (11101000001)2 d. (1010110001000100)2
a. (01000010)2 b. (11011001)2 c. (00111111010)2 d. (1100110111011011)2
a. (FO)16 b. (FB)16 c. (044C)16 d. (6358)16 e. (1B580)16
a. When dealing with a bit or group of bits.
b. For lengthy numbers that would be inconvenient to write out as binary,
and that could be grouped as nibbles.
All the same.

For more information and all the solutions, please go to www.proprep.uk


For any questions please contact us at +44-161-850-4375 or [email protected]
3
© All rights in this workbook reserved to proprep™
Principles of Programming

Signed and twos complement


Questions
Given the binary number (1010110)2, state the value in decimal for:
a. an unsigned number
b. a signed number using sign and magnitude
c. a signed number using two’s complement

Given the binary number (101100110110)2, state the value in decimal for:
a. an unsigned number
b. a signed number using sign and magnitude
c. a signed number using two’s complement

Convert the decimal number -256 into a binary representation using:


a. sign and magnitude
b. two’s complement

Convert the decimal number -1394 into a binary representation using:


a. two’s complement
b. sign and magnitude

State the range of a 12 bit number, using:


a. two’s complement
b. sign and magnitude

How many bits would be required to store the decimal number -32000 in two’s
complement representation?

Assume the following operations are carried out using 12 bits.


Add the two unsigned binary numbers, showing your working in each case:
a. (10101100)2, (01010010)2
b. (11010101)2, (11011011)2
c. (1100111011)2, (1000101010)2

Assume the following operations are carried out using 8 bits. Using binary addition
subtract the second number from the first, showing your working in each case:
a. (1010111)2, (11011)2
b. (11101111)2, (1101001)2
c. (0111)2, (110101)2

For more information and all the solutions, please go to www.proprep.uk


For any questions please contact us at +44-161-850-4375 or [email protected]
4
© All rights in this workbook reserved to proprep™
Principles of Programming

Answer Key
a. (86)10 b. (-22)10 c. (-42)10
a. (2870)10 b. (-822)10 c. (-1226)10
a. (1100000000)2 b. (100000000)2
a. (101010001110)2 b. (110101110010)2
a. -2048…2047 b. -2047…2047
16
a. (000011111110)2 b. (000110110000)2 c. (010101100101)2
a. 00111100 b. 10000110 c. 11010010

For more information and all the solutions, please go to www.proprep.uk


For any questions please contact us at +44-161-850-4375 or [email protected]
5
© All rights in this workbook reserved to proprep™
Principles of Programming

Fixed and floating point


Questions
Using 8 bit fixed point fractional representation, with 3 bits for the fractional part,
convert the following decimal numbers to binary:
a. 27.5
b. 30.25
c. 15.75
d. 9.375

Assuming you have 12 bits available, encode the following decimal numbers in fixed point
binary representations:
a. 17.5
b. -37.75
c. 253.0625

Assuming a 5 bit mantissa, and 3 bit exponent in two’s complement,


convert the following binary encodings into denary:
a. 01011 001
b. 10101 010

Assuming two’s complement encoding, and given an 8 bit mantissa and 4 bit exponent,
convert the following into denary:
a. 00100000 1011
b. 11101101 0110
c. 10110000 1100

Using sign and magnitude for the mantissa and two’s complement for the exponent,
express the following as binary with a sign bit as the MSB, followed by 4 bits for the
exponent, and 11 bits for the mantissa (SEEEEMMMMMMMMMMM):
a. 13.375
b. -31.25
c. -92.9375

Normalize the following binary representations, all of which use a two’s complement 16 bit
encoding with the least significant 4 bits representing the mantissa:
a. 0001010101110101
b. 1111010110000100
c. 1110111000001110

For more information and all the solutions, please go to www.proprep.uk


For any questions please contact us at +44-161-850-4375 or [email protected]
6
© All rights in this workbook reserved to proprep™
Principles of Programming

Answer Key
a. (11011100)2 b. (11110010)2 c. (01111110)2 d. (01001011)2
a. (000010001100)2 b. (111011010010)2 c.(111111010001)2
a. (1.375)10 b. (-2.75)10
a. (0.0078125)10 b. (-9.5)10 c. (-0.0390625)10
a. (0001111010110000)2 b. (1010011111010000)2 c. (1011010111001110)2
a. (0101010111000011)2 b. (1010110000000001)2 c. (1011100000001100)2

For more information and all the solutions, please go to www.proprep.uk


For any questions please contact us at +44-161-850-4375 or [email protected]
7
© All rights in this workbook reserved to proprep™

You might also like