User Tools

Site Tools


notes:c4eng:fall2023:projects:dtr0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:c4eng:fall2023:projects:dtr0 [2023/09/12 22:39] – [PROGRAM SPECIFICATIONS] mwinter4notes:c4eng:fall2023:projects:dtr0 [2023/09/14 00:42] (current) – [DATA TYPES IN C] lbond1
Line 40: Line 40:
 **Signed int**- This type of data occupies 2 or 4 bytes of memory (16 or 32 bits) depending on the compiler and allows expressing a maximum of 65,536 at 2 bytes or 4,294,967,296 values at 4 bytes. Signed short int can contain both positive and negative values along with zero. The range of values is from -32,768 to 32,767 at 2 bytes or -2,147,483,648 to 2,147,483,647 at 4 bytes. **Signed int**- This type of data occupies 2 or 4 bytes of memory (16 or 32 bits) depending on the compiler and allows expressing a maximum of 65,536 at 2 bytes or 4,294,967,296 values at 4 bytes. Signed short int can contain both positive and negative values along with zero. The range of values is from -32,768 to 32,767 at 2 bytes or -2,147,483,648 to 2,147,483,647 at 4 bytes.
  
-**Unsigned int**- This type of data occupies 2 or 4 bytes of memory (16 or 32 bits) depending on the compiler and allows expressing a maximum of 65,536 at 2 bytes or 4,294,967,296 values at 4 bytes. Signed short int can contain only positive values along with zero. The range of values is from 0 to 65,535 at 2 bytes or 0 to 4,294,967,295 at 4 bytes.+**Unsigned int**- This type of data occupies 2 or 4 bytes of memory (16 or 32 bits) depending on the compiler and allows expressing a maximum of 65,536 at 2 bytes or 4,294,967,296 values at 4 bytes. Unsigned short int can contain only positive values along with zero. The range of values is from 0 to 65,535 at 2 bytes or 0 to 4,294,967,295 at 4 bytes.
  
-**Signed long int**- This type of data occupies 4 or 8 bytes (32 or 64 bits) depending on the compiler and allows expressing a maximum of 4,294,967,295 at 4 bytes or 18,446,744,073,709,551,616 at 8 bytes. Signed long int can contain a range of values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. +**Signed long int**- This type of data occupies 4 or 8 bytes (32 or 64 bits) depending on the compiler and allows expressing a maximum of 4,294,967,295 at 4 bytes or 18,446,744,073,709,551,616 at 8 bytes. Signed long int can contain a range of values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
  
-**Unsigned long long int**- This type of data occupies 2,4 or 8 bytes of memory (16,32 or 64 bits) depending on the compiler and allows expressing a maximum of 65,536 at 2 bytes, 4,294,967,296 values at 4 bytes or 18,446,744,073,709,551,615 at 8 bytes. Unsigned long long int can contain a range of values from 0 to 18,446,744,073,709,551,615.+**Unsigned long int**- This type of data occupies 4 or 8 bytes (32 or 64 bits) depending on the compiler and allows expressing a maximum of 4,294,967,295 at 4 bytes or 18,446,744,073,709,551,616 at 8 bytes. Unsigned long int can contain a range of values from 0 to 18,446,744,073,709,551,615. 
  
 +**Signed long long int**- This type of data occupies 2,4 or 8 bytes of memory (16,32 or 64 bits) depending on the compiler and allows expressing a maximum of 65,536 at 2 bytes, 4,294,967,296 values at 4 bytes or 18,446,744,073,709,551,615 at 8 bytes. Signed long long int can contain a range of values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
 +
 +
 +**Unsigned long long int**- This type of data occupies 2,4 or 8 bytes of memory (16,32 or 64 bits) depending on the compiler and allows expressing a maximum of 65,536 at 2 bytes, 4,294,967,296 values at 4 bytes or 18,446,744,073,709,551,615 at 8 bytes. Unsigned long long int can contain a range of values from 0 to 18,446,744,073,709,551,615.
  
 +Due to the limitations of our Pi's and compiler, the max bit count should be 32, this will mean that un/signed long long and un/signed long types will share values
  
 ========COMPILE CODE========= ========COMPILE CODE=========
Line 74: Line 79:
  
 **%hu** - Specifies the output type as half of an unsigned int (4/2 =2 bytes) **%hu** - Specifies the output type as half of an unsigned int (4/2 =2 bytes)
 +
 +**%u**  - Specifies the output type as an unsigned int (4 bytes)
 +
 +**%d**  - Specifies the output type as a signed int (4 bytes)
  
 **%lld**- Specifies the output type as a signed long long int **%lld**- Specifies the output type as a signed long long int
Line 80: Line 89:
  
 **%p**- Specifies the output type as an address in hexadecimal digits   **%p**- Specifies the output type as an address in hexadecimal digits  
 +
 +Essentially, %u and %d are the bases for these, adding H before the u or d will half the byte count, and adding L's will increase the byte count. Within the project, each next data type increases in size. To represent this, you will change the specifier, mainly by increasing the byte count specified. 
 =====PROGRAM SPECIFICATIONS===== =====PROGRAM SPECIFICATIONS=====
  
-Within <wrap hi>dtr0.c</wrap> you will find multiple sections, commented respective to their task. You will write very similar code for the required sections, each section meant for a different data type in C (and titled appropriately). As an example of the code you'll need, all the tasks for **signed char** have already been completed. It is your job to study the given code and implement it elsewhere in the program where appropriate to create sections for each data type, which will be formatted and printed to the terminal.  +Within <wrap hi>dtr0.c</wrap> you will find multiple sections, commented respective to their task. You will write very similar code for the required sections, each section meant for a different data type in C (and titled appropriately). As an example of the code you'll need, all the tasks for **signed char** have already been completed. It is your job to study the given code and implement it elsewhere in the program where appropriate to populate sections for each data type, which will be formatted and printed to the terminal.  
  
-These sections will contain multiple print statements to display information and formatting. They will also contain some computations for determining some of the information that will be printed to the screen. For example, take the following statement: +These sections, when completed, will contain multiple print statements to display information and formatting. They will also contain some computations for determining some of the information that will be printed to the screen. For example, take the following statement: 
  
 <code> <code>
Line 91: Line 102:
  
 This statement informs us of the possible distinct values, which we will need for our output. This statement informs us of the possible distinct values, which we will need for our output.
 +
 +To get an idea of what your output should look like for each section, you can compile and run the program before even making any modifications. Notice that there is formatting to align the information in the right "column". There are seven values paired with their respective textual descriptions to the left. Some of these values are dynamic and computed by our code, and some of these values are static or hard-coded. 
  
 ------- -------
 If you are leaving nano use this command to save, if you don't you will get a save file every time you return to lab46. If you are leaving nano use this command to save, if you don't you will get a save file every time you return to lab46.
 <blockquote> hg commit -m "brief description of changes commit"</blockquote> <blockquote> hg commit -m "brief description of changes commit"</blockquote>
 +
 +=====Submit=====
 +Once your program is complete you will need to submit all your files.  To do this, navigate to the directory with your dtr0 program.
 +<blockquote>
 +cd src/fall2023/c4eng/dtr0
 +</blockquote>
 +
 +
 +Once you are in the directory, use "ls" to see what files are here. Be sure to include all of these files with your submission.
 +<blockquote>
 +submit DESIG PROJECT File1 File2 File3 ... FileN
 +</blockquote>
 +
notes/c4eng/fall2023/projects/dtr0.1694558377.txt.gz · Last modified: 2023/09/12 22:39 by mwinter4