This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
user:mowens3:portfolio:cprogproject0 [2012/02/09 22:02] – [Code] mowens3 | user:mowens3:portfolio:cprogproject0 [2012/02/09 22:08] (current) – [Reflection] mowens3 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Project: | ||
+ | A project for COURSENAME by YOUR NAME during the SEMESTER YEAR. | ||
+ | |||
+ | This project was begun on DATE and is anticipated to take TIME UNIT to complete. Project was completed on MONTH DAY, YEAR. | ||
+ | |||
+ | =====Objectives===== | ||
+ | State the purpose of this project. What is the point of this project? What do we hope to accomplish by undertaking it? | ||
+ | |||
+ | =====Prerequisites===== | ||
+ | In order to successfully accomplish/ | ||
+ | |||
+ | * ability to log into Lab46 | ||
+ | * ability to edit text files | ||
+ | * ability to compile C source code | ||
+ | * ability to read and appropriately react to compiler messages during compilation | ||
+ | * ability to execute compiled code | ||
+ | * knowledge of the size of a byte, how many combinations are possible therein | ||
+ | |||
+ | =====Background===== | ||
+ | To determine the possible values for each data type | ||
+ | |||
+ | =====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, how many numbers can exist within each type, and what are the ranges available for each type? | ||
+ | |||
+ | A program will be written that will display (to STDOUT) the size (in bytes), the lower and upper bounds of each studied type, and display the total quantity of values possible with each type. | ||
+ | |||
+ | The data types covered for this project will include: | ||
+ | |||
+ | * unsigned char | ||
+ | * signed char | ||
+ | * unsigned short int | ||
+ | * signed short int | ||
+ | * unsigned int | ||
+ | * signed int | ||
+ | * unsigned long int | ||
+ | * signed long int | ||
+ | * unsigned long long int | ||
+ | * signed long long int | ||
+ | |||
+ | The **sizeof()** and **printf()** functions, as well as arithmetic operators, will be utilized in performing much of the work. | ||
+ | |||
+ | |||
+ | =====Code===== | ||
+ | |||
+ | <code c># | ||
+ | #include < | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | unsigned long long int quantity = 0; | ||
+ | unsigned char uc = 0; | ||
+ | signed char sc = 0; | ||
+ | unsigned short int usi = 0; | ||
+ | signed short int ssi = 0; | ||
+ | unsigned int ui = 0; | ||
+ | signed int si = 0; | ||
+ | unsigned long int uli = 0; | ||
+ | signed long int sli = 0; | ||
+ | unsigned long long int ulli = 0; | ||
+ | signed long long int slli = 0; | ||
+ | printf(" | ||
+ | printf(" | ||
+ | quantity = (unsigned char)(uc -1) +1; | ||
+ | printf(" | ||
+ | |||
+ | printf(" | ||
+ | quantity = (unsigned char)pow(2, sizeof(sc)*8); | ||
+ | printf(" | ||
+ | printf(" | ||
+ | |||
+ | printf(" | ||
+ | printf(" | ||
+ | quantity = (unsigned short int)(usi -1) +1; | ||
+ | printf(" | ||
+ | |||
+ | |||
+ | printf(" | ||
+ | quantity = (unsigned short int)pow(2, sizeof(ssi)*16); | ||
+ | printf(" | ||
+ | printf(" | ||
+ | |||
+ | printf(" | ||
+ | printf(" | ||
+ | quantity = (unsigned int)(ui -1); | ||
+ | printf(" | ||
+ | |||
+ | printf(" | ||
+ | quantity = (unsigned int)pow(2, sizeof(si)*32); | ||
+ | printf(" | ||
+ | printf(" | ||
+ | |||
+ | printf(" | ||
+ | printf(" | ||
+ | quantity = (unsigned long int)(uli -1); | ||
+ | printf(" | ||
+ | |||
+ | printf(" | ||
+ | quantity = (unsigned long int)pow(2, sizeof(sli)*64); | ||
+ | printf(" | ||
+ | printf(" | ||
+ | |||
+ | printf(" | ||
+ | printf(" | ||
+ | quantity = (unsigned long long int)(ulli -1); | ||
+ | printf(" | ||
+ | |||
+ | printf(" | ||
+ | quantity = (unsigned long long int)pow(2, sizeof(slli)*64); | ||
+ | printf(" | ||
+ | printf(" | ||
+ | |||
+ | return(0); | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | =====Execution===== | ||
+ | |||
+ | < | ||
+ | the range of an unsigned char is 0 to 255 | ||
+ | An unsigned char can store 256 unique values | ||
+ | |||
+ | A signed char is 1 bytes | ||
+ | The range of a signed char is -127 to 126 | ||
+ | A signed char can store 255 unique values | ||
+ | |||
+ | An unsigned short int is 2 bytes | ||
+ | the range of an unsigned short int is 0 to 65535 | ||
+ | An unsigned char can store 65536 unique values | ||
+ | |||
+ | A signed short int is 2 bytes | ||
+ | the range of a signed short int is -32767 to 32766 | ||
+ | A signed short int can store 65535 unique values | ||
+ | |||
+ | An unsigned int is 4 bytes | ||
+ | the range of an unsigned int is 0 to 4294967295 | ||
+ | An unsigned int can store 4294967295 +1 unique values | ||
+ | |||
+ | A signed int is 4 bytes | ||
+ | the range of a signed int is -2147483647 to 2147483646 | ||
+ | A signed int can store 4294967295 unique values | ||
+ | |||
+ | An unsigned long int is 8 bytes | ||
+ | the range of an unsigned long int is 0 to 18446744073709551615 | ||
+ | An unsigned long int can store 18446744073709551615 +1 unique values | ||
+ | |||
+ | A signed long int is 8 bytes | ||
+ | the range of a signed long int is -9223372036854775807 to 9223372036854775806 | ||
+ | A signed long int can store 18446744073709551615 unique values | ||
+ | |||
+ | An unsigned long long int is 8 bytes | ||
+ | the range of a unsigned long long int is 0 to 18446744073709551615 | ||
+ | A unsigned long long int can store 18446744073709551615 +1 unique values | ||
+ | |||
+ | A signed long long int is 8 bytes | ||
+ | the range of a signed long long int is -9223372036854775807 to 9223372036854775806 | ||
+ | A signed long long int can store 18446744073709551615 unique values | ||
+ | |||
+ | lab46: | ||
+ | </ | ||
+ | |||
+ | =====Reflection===== | ||
+ | I learned the sizes of the data types for this specific computer setup, but nothing much else. | ||
+ | =====References===== | ||
+ | In performing this project, the following resources were referenced: | ||
+ | |||
+ | * URL1 | ||
+ | * URL2 | ||
+ | * URL3 (provides useful information on topic) | ||
+ | * URL4 | ||
+ | |||
+ | Generally, state where you got informative and useful information to help you accomplish this project when you originally worked on it (from Google, other wiki documents on the Lab46 wiki, etc.) |