Table of Contents

Corning Community College

CSCS2330 Discrete Structures

PROJECT: Units Of Measurement (UOM0)

Background

In computing, we're constantly interacting with data and information. While these terms are frequently interchanged, they actually both hold useful and distinct meanings.

The word “data” is defined as meaning: the quantities, characters, or symbols on which operations are performed by a computer, being stored and transmitted in the form of electrical signals and recorded on magnetic, optical, or mechanical recording media.

The word “information”, on the other hand, is defined as: what is conveyed or represented by a particular arrangement or sequence of things. It is the result of data being organized, processed, stored, or transmitted by a computer.

For example, “data” might refer to some quantity of 1s and 0s stored on a disk. “Information”, on the other hand, is applying some larger context or pattern to that otherwise meaningless sequence of bits. A set of numbers can be construed as data, whereas a list of prime numbers? Information.

Another defining characteristic of information is that we can use it to better communicate ideas. As there is no single perspective or point of reference on all information, to avoid becoming unnecessarily long-winded, we enhance our information even more with the addition of units– further classifications that we can use to compare and evaluate information.

Look around: information in the world is filled with units. We rely on units to convey information: how many miles per hour are we going? How many litres of water can be placed in a container? How much does that item weigh (factor in shipping costs)?

And misunderstanding units can lead to miscommunication, from losing Mars rovers to receiving unexpected overcharge fees on cell phone bills (https://www.youtube.com/watch?v=MShv_74FNWU).

In the realm of computing, we quantify our information in units of bits. Now, we seldom relate information in bits, but instead easier to manage units like bytes, kilobytes, megabytes, etc.

At the simplest level, most of us understand that (at least in recent decades) 1 byte is equal to 8 bits. But so often, our typical storage capacities are huge and expressing them in just bytes would be rather unwieldy- instead we further simplify by using kilobytes, megabytes, gigabytes, etc.

Using the metric system, we recognize the following prefixes:

+---------+-----------------+
|  prefix |  value          |
+---------+-----------------+
|  kilo   |  1000           |
|  mega   |  1000000        |
|  giga   |  1000000000     |
|  tera   |  1000000000000  |
+---------+-----------------+

Historically, however, due to the computer's grouping of 8-bits per byte (instead of other measurements which we group in collections of 10), which meant that instead of a kilobyte being 1000 bytes, it was 1024 bytes.

In recent years, the metric gestapo convinced the computing realm to similarly line up to even units of 10. Marketing people loved this, as they could now sell you a 1TB hard drive but there'd actually be less capacity than was historically sold.

To retain context, a new class of units were created to encapsulate the old 8-based byte storage. These received a lowercase “i” in their unit:

+------------------+---------------------------------------------+
|  prefix          |  value                                      |
+------------------+---------------------------------------------+
|  kibiByte (kiB)  |  1024                                       |
|  MibiByte (MiB)  |  1024 * 1024 = 1048576                      |
|  GibiByte (GiB)  |  1024 * 1024 * 1024 = 1073741824            |
|  TibiByte (TiB)  |  1024 * 1024 * 1024 * 1024 = 1099511627776  |
+------------------+---------------------------------------------+

Put side by side, we see:

+------------------+---------------------------------------------+
|  prefix          |  value                                      |
+------------------+---------------------------------------------+
|  kilobyte (kB)   |  1000 bytes                                 |
|  kibiByte (kiB)  |  1024 bytes                                 |
|  MegaByte (MB)   |  1000 * 1000 = 1000000 bytes                |
|  MibiByte (MiB)  |  1024 * 1024 = 1048576 bytes                |
|  GigaByte (GB)   |  1000 * 1000 * 1000 = 1000000000 bytes      |
|  GibiByte (GiB)  |  1024 * 1024 * 1024 = 1073741824 bytes      |
+------------------+---------------------------------------------+

units

Your program will recognize at least the following units of data:

Task

Write a program that prompts the user for 3 pieces of input:

Example output, units of data

lab46:~/src/SEMESTER/discrete/uom0$ ./uom0
Enter source value: 2048
Enter source unit: kiB
Enter destination unit: Db

2048 kiB == 1677721.6250 Db
lab46:~/src/SEMESTER/discrete/uom0$ 

Verification

For additional help in attaining output and formatting compliance, I have included a copy of a working implementation, which abides by the project specifications. Please compare its output against that of your implementation.

Run the provided “verify” program with whatever combination of inputs needed to obtain the output that your implementation needs to reproduce.

You can run the verify program with “make check”

Additional requirements

In your finished, submitted product:

The resultant program MUST be well-organized, easy-to-read, consistently indented visually showing the encapsulated levels of logic, and be thoroughly commented to explain each significant step of the process.

Submission Criteria

To be successful in this project, the following criteria must be met:

Submit Tool Usage

Let's say you have completed work on the project, and are ready to submit, you would do the following (assuming you have a program called uom0.c):

lab46:~/src/fall2021/discrete/uom0$ make submit

You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.

I'll be evaluating the project based on the following criteria:

52:uom0:final tally of results (52/52)
*:uom0:grabbed project by the Sunday before due date [6/6]
*:uom0:clean compile, no compiler messages [10/10]
*:uom0:runtime tests pass [20/20]
*:uom0:adequate modifications [10/10]
*:uom0:tracked in lab46 semester repo [6/6]

Additionally: