CIS3355: Business Data Structures in C/C++

Dr. Peeter Kirs

 

Basic Data Types

Short Answer/Problem Questions

 

NOTE: Checking the answers before you have tried to answer the questions doesn’t help you at all

 

0010.  How many different combinations can we have when adding binary digits together? What are they?

 

            See Solution

 

0020.  Show how you would add the following binary numbers:

 

a.   1011101 + 101111

b.   1110111 + 101001

c.   1110110100 + 101001 + 111101

 

See Solution

 

0030. What happens when we add the add the ASCII characters ‘1’ and ‘7’ together? Why?

 

See Solution

 

0040. What is the difference between a character and a numeric value?

 

See Solution

 

0050. How do we represent numeric values in binary?

 

See Solution

 

0055. How do we represent numeric values from 0 to 20 in Binary (Assume we are using 8-bits)?

 

See Solution

 

0060. If you were asked to convert 4,203 inches to yards, feet and inches, how would you do it?

 

See Solution

 

0065. If you were asked to convert 52,897,605 seconds to years, months, days, hours and seconds (assume 30 days per month), how would you do it?

 

See Solution

 

0100.  Convert the following decimal numbers to binary.

 

a.   34

b.   63

c.   128

 

See Solution

 

0110.  Without actually converting the numbers 84, 137, and 693 into binary, what can we predict about how the numbers will appear in binary?

 

See Solution

 

0115.  How can we predict that 7 will be 1112, 64 will be 10000002 and 1023 will be 11111111112?

 

See Solution

 

0150.  In what different ways can we express the number 9,76510?

 

See Solution

 

0160.  Convert the following binary numbers to decimal:

 

a.   111

b.   1011011

c.   1111111111

 

See Solution

 

0200.  Why do we use octal and hexidecimal?

 

See Solution

 

0210.  Create the binary to octal and binary to hex tables.

 

See Solution

 

0220.  Why must we use the letters A, B, C, D, E, and F to represent the numbers 10, 11, 12, 13, 14, and 15 (respectively)?

 

See Solution

 

0230.  Convert the following decimal values to Octal and Hexidecimal:

 

a.  14

b.   93

c.   3119

 

          See Solution

 

0235. Convert the following binary values to Octal and Hexidecimal.

 

a.  1011

b.  10101110

c.   111111111111

 

          See Solution

 

0240.  Convert the following octal values to binary and Hexidecimal:

 

a.  65

b.  173

c.   3102

 

          See Solution

 

0245.  Convert the following hexidecimal values to binary and octal:

 

a.  65

b.  7B

c.   FFF

 

          See Solution

 

0300.  How would the character ‘5’ be stored in RAM (EXACTLY)?

 

          See Solution

 

0310.  Why are 8-bits insufficient for storing numeric values?

 

          See Solution

 

0320. How do we store integers?

 

          See Solution

 

0340. What is the difference between signed and unsigned integers (and characters)? What is the default?

 

          See Solution

 

0345. Are signed integers stored differently than unsigned integers?

 

          See Solution

 

0347. What is the range of integers?

 

          See Solution

 

0350. How are negative numbers stored?

 

          See Solution

 

0360. What is one’s compliment? What is two’s compliment? Which do we use and why??

 

          See Solution

 

0370.  Show how you would subtract 35 from 76 using both one’s compliment and two’s compliment.

 

          See Solution

 

0380.  Show how you would subtract 76 from 35 using both one’s compliment and two’s compliment.

 

          See Solution

 

0400.  Express the numbers 76,809.78 and –0.000678 in exponential notation. Why is this useful?

 

          See Solution

 

0405.  What three components must we keep track-of in storing real numbers (floats)? Illustrate the components using the real number -809.7032.

 

          See Solution

 

0410.  How many bits do we need to allocate to each component?

 

          See Solution

 

0420.  What is the value of adding more bits to the mantissa? How can this be illustrated?

 

          See Solution

 

0425.  Given the standard number of bits allocated to the mantissa (24), what level of precision can we get and why?

 

          See Solution

 

0426.  Suppose we only allocated 18-bits to the mantissa. What level of precision can we get and why?

 

          See Solution

 

0430.  What is the value of adding more bits to the characteristic of the exponent? How can this be illustrated?

 

          See Solution

 

0435.  What will be the range of the characteristic of the exponent given the traditional 7-bits allocated to it? What does this mean?

 

          See Solution

 

0436.  Suppose we only allocated 5-bits to the characteristic of the exponent. What level of magnitude can we get and why?

 

          See Solution

 

0450.  What is the range of real numbers?

 

          See Solution

 

0460. What if I need more precision?

 

          See Solution

 

0465. How are the bits allocated to the data types double and long double?

 

          See Solution

 

 

SOME MORE REVIEW QUESTIONS:

0999. List all of the different data-types, how many bits are associated with it, the range (for integers), and the level of precision (for real numbers).

 

          See Solution

 

1000. Convert the following decimal numbers to binary (assume a 16 bit Short Integer: 1 bit for the sign, 15 bits for the value). If necessary, assume two’s complement.

 

           a.        100                         d.      ‑87

           b.        978                         e.      ‑5,345

           c.      32,767                     f.       -32,789

 

          See Solution

 

2000. Convert the following Binary numbers (1 bit sign, 15 bit value) to Decimal, Octal and Hex

 

          a.       0,110010111011111                             

          b.       0,001101110111011

          c.       1,010100111001100                           (One’s Complement)

          d.       1,111111111111010                           (Two’s Complement)

 

          See Solution

 

3000. Add the following numbers in binary:

 

          a.       7810 + 7810 using one’s complement

          b.       -AB16 + 708  using one’s complement

          c.       4395 + 647 using two’s complement

 

          See Solution

 

4000. You are building a database of addresses. The question was raised as to whether zip codes should be stored as numbers or strings. Explain what the differences are, and what the advantages/disadvantages are for each.

 

          See Solution

 

5000. A new machine has been developed which will use a 20-bit register. Reals will be stored with a 1‑bit sign and a 6‑bit exponent. What will be the range for reals? What will be the range for Integers?

 

          See Solution

 

5010. I have just built a new machine. It uses a 6-bit character set, which I have grouped together as something I call a ‘snack’. Other than that, the lay-out of data types cor­responds to traditional machine architecture. It uses two’s compliment for negative values. Characters will require 1 snack of storage of per character: given the 6-bits, standard character set will use 1-bit for parity; the extended character set will use all 6-bits of the snack). An integer will use two snacks, of which 1-bit (the left-most bit) will be used to represent the sign. Longs will have twice the storage of integers. Reals (floats) will use 4 snacks: 1-bit for the sign, 6-bits for the characteristic of the exponent, and the remainder for the mantissa.

 

a.         How many characters can I represent with a standard meal character set?

b.         What is the range of a signed integer?

c.         What is the largest long I can have (the formula is OK)?

d.         What Level of precision will real numbers (floats) have?

e.         Using my snack machine, I issued the command:    int a = -38;

            Show EXACTLY how this will be stored in RAM in my new machine.

 

          See Solution

 

5050.   I have invented a new light switch. In contrast to a normal light switch (which is either ‘off’ or ‘on’), it has three positions: Off, Low and High. That means with each switch I can represent three different pieces of information (a ternary situation). I am going to build a computer using this as the micro-switch and applying the same principles as a binary computer.

 

            My basic unit will be a ‘chomp’ (as opposed to a byte). I am going to include the entire extended ASCII character set in the data type we call ‘char’ using one chomp. I don’t have to worry about parity, since my machine will be perfect.

 

            I will only have one type of integer.  It will consist of two (2) chomps. All my integers will be signed, and I plan to use one of my three position light switches to represent the sign.

 

            My real numbers will require three (3) chomps. One (1) switch will be used for the sign (just like my integers). I am going to assign 5 of my light switches to the characteristic of the exponent.

 

 

(Note: with the exception of the first question (below) each of these can be answered using a formula (only), although the numeric answers are not too difficult)

 

1.      How many of my ternary light switches do I need to group together to include the entire extended ASCII character set (i.e., how many switches are in a ‘chomp’)?

 

2.      What will be the range of integers using 2 chomps?

 

3.      What will be my range of magnitude using my ‘chomp’ machine?

 

4.     What will be my level of precision using my ‘chomp’ machine?

 

          See Solution

 

 

PART II. Questions which you should be able to answer, WITHOUT being given the answers.

 

10010.   Given two (2) binary digits, how many different combinations are there? What are they?

 

10020.   Add the following binary digits together:

 

               111010110 + 10010011 + 101 + 10011101 + 1010010011 + 100111011

 

               (MAKE SURE YOU CAN SHOW ALL OF YOUR WORK)

 

10040.   Convert 154,816,978,613 seconds to centuries, decades, years, months, days (assume 30 days per month), hours, minutes and seconds