User Tools

Site Tools


Sidebar

projects

wcp1 (due 20240124)
pct0 (bonus; due 20240125)
pct1 (bonus; due 20240125)
abc0 (due 20240131)
pct2 (due 20240131)
wcp2 (due 20240131)
gtf0 (due 20240207)
pct3 (bonus; due 20240207)
wcp3 (due 20240207)
dtr0 (due 20240214)
pct4 (due 20240214)
wcp4 (due 20240214)
bwp1 (bonus; due 20240228)
mmf0 (due 20240228)
pct5 (bonus; due 20240228)
wcp5 (due 20240228)
cnv0 (due 20240306)
gfo0 (due 20240306)
pct6 (due 20240306)
wcp6 (due 20240306)
cnv1 (due 20240313)
fwg0 (due 20240313)
pct7 (bonus; due 20240313)
wcp7 (due 20240313)
fwg1 (due 20240320)
pct8 (due 20240320)
wcp8 (due 20240320)
pct9 (bonus; due 20240327)
wcp9 (due 20240327)
bwp2 (bonus; due 20240410)
fwg2 (due 20240410)
fwg3 (due 20240410)
gfo1 (due 20240410)
pctA (due 20240410)
wcpA (due 20240410)
cpp0 (due 20240417)
pctB (bonus; due 20240417)
wcpB (due 20240417)
cpp1 (due 20240424)
pctC (due 20240424)
wcpC (due 20240424)
pctD (bonus; due 20240501)
wcpD (bonus; due 20240501)
gfo2 (due 20240508)
pctE (bonus; due 20240508)
wcpE (bonus; due 20240508)
EoCE (due 20240516)
haas:spring2024:cprog:projects:dtr0

Corning Community College

CSCS1320 C/C++ Programming

PROJECT: Data Type Resources (DTR0)

OBJECTIVE

To begin our exploration of programming, starting with an investigation into the various data types available in C, along with their properties.

GRABIT

To assist with consistency across all implementations, data files for use with this project are available on lab46 via the grabit tool. Be sure to obtain it and ensure your implementation properly works with the provided data.

lab46:~/src/SEMESTER/DESIG$ grabit DESIG PROJECT

Please study any provided code or supporting documents, and look up, experiment, and ask questions on aspects that you do not understand.

Scope

This project will be exploring the nature of some of the data types available to us in the C Programming Language. How much space is allocated to each type, and what are the ranges available for each type?

A program is provided that will display (to STDOUT) the size (in bytes), the lower and upper bounds of each studied type, and some other related information.

The data types covered for this project will include signed and unsigned variations of:

  • char
  • short int
  • int
  • long int
  • long long int

The sizeof() and printf() functions, as well as arithmetic and logical operators, will be utilized in performing much of the work.

Task

Your task is to first study and understand what the provided code is doing. It is expected you will ask questions on discord to gain clarification.

Once you have an understanding of what is going on, extend the code to support the other types (both signed and unsigned). In total, you should have TEN total sections.

EDIT

You will want to go here to edit and fill in the various sections of the document:

DTR0

REPOSITORY STEPS

BUILD THE CODE

RUN THE PROGRAM

BACKGROUND

INTEGER VALUES

An integer is a number that has no fractional component, so 2, 6, -15, and 17356 are all considered integers, while 13½, -1/12, π, and 5.2 are not. For our use, we split integers into 2 categories, signed and unsigned. A signed integer is any whole number, negative or positive, while an unsigned integer is a strictly positive whole number (and zero).

In this project we are looking at 10 different types of data values, that are all variations of integers with different byte sizes:

signed long long int --- 8 bytes
unsigned long long int --- 8 bytes
signed long int --- 8 bytes
unsigned long int --- 8 bytes
signed int --- 4 bytes
unsigned int --- 4 bytes
signed half int --- 2 bytes
unsigned half int --- 2 bytes
signed char --- 1 byte
unsigned char --- 1 byte
REPRESENTATION: BASE 2 (BINARY)

Each of the data value types has an associated size, ranging from 1 byte (8 bits) to 32 byte (256 bits), so the length of the number in binary will be given based on the type. For example:

unsigned int:
4 bytes
0000000000000000000000000000000

unsigned half int:
2 bytes
0000000000000000

Whether or not the data type is signed changes how the first bit of the number interacts with the rest, in a signed number the first bit acts as a positive or negative sign For example:

signed half half int
1 Byte
Binary: 10000000
Decimal: -128
Binary: 00000000
Decimal: 0
 

For further information on how negative act in binary try looking here:

https://en.wikipedia.org/wiki/Two%27s_complement

Each place value in binary is worth double the previous

Ex:      1 1 1 1
Is worth 8 4 2 1

To convert a binary number to decimal, just add each place value Ex:

11010010
(1*128)+(1*64)+(0*32)+(1*16)+(0*8)+(0*4)+(1*2)+(0*1)
=210
REPRESENTATION: BASE 16 (HEXADECIMAL)

Hexadecimal Table:

0 1 2 3 4 5 6 7 8 9 A B C D E F

Hex     |Binary     |Decimal
0        0000        0
1        0001        1
2        0010        2
3        0011        3
4        0100        4
5        0101        5
6        0110        6
7        0111        7
8        1000        8
9        1001        9
A        1010        10
B        1011        11
C        1100        12
D        1101        13
E        1110        14
F        1111        15
-----------------------
10       00010000    16
20       00100000    32
30       00110000    48
40       01000000    64
50       01010000    80
60       01100000    96
70       01110000    112 
80       10000000    128
90       10010000    144
A0       10100000    160
B0       10110000    176
C0       11000000    192
D0       11010000    208
E0       11100000    224
F0       11110000    240
-------------------------
11       00010001    17
12       00010010    18
13       00010011    19
14       00010100    20
15       00010101    21
16       00010110    22
17       00010111    23
18       00011000    24
-------------------------
FF       11111111    255
100     100000000    256

-Single digit-

  5 + A =
  (5) + (10)
  Decimal = 15
  Hexadecimal = F
  
  MAX SINGLE = F or 15 or 1111

-Double Digit-

  1F + AB
  ((16*1)+15) + ((16*10)+11)
  Decimal = 31 + 171 = 202
  Hexadecimal = CA
  
  MAX DOUBLE DIGIT = FF or 255 or 11111111
STORAGE: BITS AND BYTES
BITWISE LOGIC: AND

An AND logic gate has 2 inputs/conditions and they both need to be met to activate.

EXAMPLE - To login you need both a valid email and password;

  (Valid email)-------
                     |
                     |--[AND]--(No login)
                     |
  (Invalid password)--     

Binary view of previous;
  ( 1 ) --------------
                     |
                     |--[AND]--( 0 )
                     |
  ( 0 ) --------------                 

-AND gate turned on-

( 1 ) --------------
                   |
                   |--[AND]--( 1 )
                   |
( 1 ) --------------     

List of all AND gate Interactions

  1. 0 & 0 = 0
  2. 0 & 1 = 0
  3. 1 & 1 = 1
  4. 1 & 0 = 0
BITWISE LOGIC: OR

An OR logic gate has 2 input/conditions, that when one or both is met, the gate activates

EXAMPLE - You can have a free ice cream cone

(1scoopOfVanilla)---
                   |
                   |--[OR]--( free ice cream )
                   |
(0scoopsOfChocolate)

(1scoopOfVanilla)---
                   |
                   |--[OR]--( free ice cream )
                   |
(1scoopsOfChocolate)

(0scoopOfVanilla)---
                   |
                   |--[OR]--(No free ice cream )
                   |
(0scoopsOfChocolate)

List of all OR gate Interactions

  1. 0 & 0 = 0
  2. 0 & 1 = 1
  3. 1 & 1 = 1
  4. 1 & 0 = 1
BITWISE LOGIC: XOR

An XOR logic gate has 2 input/conditions, that when one is met, the gate activates, cant be both

EXAMPLE - You can have a free ice cream cone, but you can only have one scoop of vanilla or chocolate

(1scoopOfVanilla)---
                   |
                   |--[XOR]--( free ice cream )
                   |
(0scoopsOfChocolate)

(0scoopOfVanilla)---
                   |
                   |--[XOR]--( free ice cream )
                   |
(1scoopsOfChocolate)

(0scoopOfVanilla)---
                   |
                   |--[XOR]--(No free ice cream )
                   |
(0scoopsOfChocolate)

(1scoopOfVanilla)---
                   |
                   |--[XOR]--(no free ice cream )
                   |
(1scoopsOfChocolate)

List of all XOR gate Interactions

  1. 0 & 0 = 0
  2. 0 & 1 = 1
  3. 1 & 1 = 0
  4. 1 & 0 = 1
BITWISE LOGIC: NOT

A NOT gate inverts the input. It only has a single input.

EXAMPLE - Its opposite day

( YES )------|[NOT]>-----( NO )

( 1 )--------|[NOT]>-----( 0 )
 

List of possible NOT gate interactions

  1. 1 = 0
  2. 0 = 1
 

SUBMISSION

To be successful in this project, the following criteria (or their equivalent) must be met:

  • Project must be submit on time, by the deadline.
    • Late submissions will lose 33% credit per day, with the submission window closing on the 3rd day following the deadline.
  • All code must compile cleanly (no warnings or errors)
    • Compile with the -Wall and --std=gnu18 compiler flags
    • all requested functionality must conform to stated requirements (either on this document or in a comment banner in source code files themselves).
  • Executed programs must display in a manner similar to provided output
    • output formatted, where applicable, must match that of project requirements
  • Processing must be correct based on input given and output requested
  • Output, if applicable, must be correct based on values input
  • Code must be nicely and consistently indented
  • Code must be consistently written, to strive for readability from having a consistent style throughout
  • Code must be commented
    • Any “to be implemented” comments MUST be removed
      • these “to be implemented” comments, if still present at evaluation time, will result in points being deducted.
      • Sufficient comments explaining the point of provided logic MUST be present
  • No global variables (without instructor approval), no goto statements, no calling of main()!
  • Track/version the source code in your lab46 semester repository
  • Submit a copy of your source code to me using the submit tool (make submit on lab46 will do this) by the deadline.

Submit Tool Usage

Let's say you have completed work on the project, and are ready to submit, you would do the following:

lab46:~/src/SEMESTER/DESIG/PROJECT$ 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.

RUBRIC

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

26:dtr0:final tally of results (26/26)
*:dtr0:used grabit for project by Sunday prior to duedate [2/2]
*:dtr0:clean compile, no compiler messages [2/2]
*:dtr0:program conforms to project specifications [20/20]
*:dtr0:code tracked in lab46 semester repo [2/2]

NOTE: spirit of the project includes using hexadecimal values and bitwise logic operators to set the pertinent upper/lower bounds.

Pertaining to the collaborative authoring of project documentation

  • each class member is to participate in the contribution of relevant information and formatting of the documentation
    • minimal member contributions consist of:
      • near the class average edits (a value of at least four productive edits)
      • near the average class content change average (a value of at least 256 bytes (absolute value of data content change))
      • near the class total content contribution average (a value of at least 1kiB)
      • no zero-sum commits: no adding in one commit then later removing in its entirety for the sake of satisfying edit requirements
    • adding and formatting data in an organized fashion, aiming to create an informative and readable document that anyone in the class can reference
    • content contributions will be factored into a documentation coefficient, a value multiplied against your actual project submission to influence the end result:
      • no contributions, co-efficient is 0.50
      • less than minimum contributions is 0.75
      • met minimum contribution threshold is 1.00

Additionally

  • Solutions not abiding by spirit of project will be subject to a 50% overall deduction
  • Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction
  • Solutions not utilizing indentation to promote scope and clarity or otherwise maintaining consistency in code style and presentation will be subject to a 25% overall deduction
  • Solutions not organized and easy to read (assume a terminal at least 90 characters wide, 40 characters tall) are subject to a 25% overall deduction
haas/spring2024/cprog/projects/dtr0.txt · Last modified: 2024/01/27 15:02 by wedge