**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?

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

a.
1011101 + 101111

b.
1110111 + 101001

c.
1110110100 + 101001 + 111101

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

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

0050. How do we represent numeric
values in binary?

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

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

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?

0100. Convert the following decimal numbers to binary.

a.
34

b.
63

c.
128

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

0115. How can we predict that 7 will be 111_{2},
64 will be 1000000_{2} and 1023 will be 1111111111_{2}?

0150. In what different ways can we express the
number 9,765_{10}?

0160. Convert the following binary numbers to
decimal:

a.
111

b.
1011011

c.
1111111111

0200. Why do we use octal and hexidecimal?

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

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)?

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

a. 14

b.
93

c.
3119

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

a. 1011

b. 10101110

c.
111111111111

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

a. 65

b. 173

c.
3102

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

a. 65

b. 7B

c.
FFF

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

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

0320. How do we store integers?

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

0345. Are signed integers stored
differently than unsigned integers?

0347. What is the range of integers?

0350. How are negative numbers
stored?

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

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

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

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

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

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

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

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

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

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

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

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

0450. What is the range of real numbers?

0460. What if I need more precision?

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

**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).

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

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)

3000. Add the following numbers in
binary:

a. 78_{10}
+ 78_{10} using one’s complement

b. -AB_{16} + 70_{8} using one’s complement

c. 439_{5}
+ 64_{7 }using two’s complement

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.

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?

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 corresponds 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.

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?

**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