BYU CS 124Lab 1 - Data Types1 Lab 1 – Data Types "Using C code, determine the size of signed and...
-
Upload
amy-leonard -
Category
Documents
-
view
212 -
download
0
Transcript of BYU CS 124Lab 1 - Data Types1 Lab 1 – Data Types "Using C code, determine the size of signed and...
Lab 1 - Data Types 1BYU CS 124
Lab 1 – Data Types
"Using C code, determine the size of signed and unsigned char, int, and long integral data types.
Demonstrate the problems of overflow.
Show how fractional numbers are represented in a computer.
Demonstrate problems that arise when using floating point data types."
Lab 1 - Data Types 2BYU CS 124
Lab 1 – Data Types
1. Acquire a Texas Instruments MSP430 LaunchPad Development Tool (R1.5).
Data Types Lab
Change RXD,TXDfrom vertical to
horizontal position.
Lab 1 - Data Types 3BYU CS 124
Lab 1 – Data Types
2. Install (if necessary) and execute TI's Code Composer Studio v5.x.
Data Types Lab
Lab 1 - Data Types 4BYU CS 124
Lab 1 – Data Types
3. Open a Terminal window in CCS
Data Types Lab
Lab 1 - Data Types 5BYU CS 124
Lab 1 – Data Types
4. Compile and execute Lab01.c
Data Types Lab
Lab 1 - Data Types 6BYU CS 124
Lab 1 – Data Types
5. Level of printf/scanf support = full
Data Types Lab
Lab 1 - Data Types 7BYU CS 124
TERMINAL MacrosData Types Lab
To output a string, use:TERMINAL(<string>);
To output a formatted number, use:TERMINAL1(<format string>,<exp>);
To output a formatted number twice, use:TERMINAL2(<string>,<exp>);
To output two different formatted numbers, use:TERMINAL3(<string>,<exp1>,<exp2>);
Examples:TERMINAL("\n\r** INTEGERS **");TERMINAL1("21+2=%d",21+2);TERMINAL2("char=%d (0x%2x)",127);
TERMINAL3("Q4.4=%f (0x%2x)",(((long)32)/16.0), 32;
Lab 1 - Data Types 8BYU CS 124
Lab 1 – Data Types
2 pts Your C program programmatically finds the largest valuesfor signed and unsigned chars, ints, and longs and themost negative values for signed chars, ints, and longs.
2 pts Your C program programmatically demonstrates data typeoverflow for chars, ints, and longs.
2 pts Your C program programmatically finds the largest positiveand most negative signed Q16.16 fixed point numbers.
2 pts Your C program programmatically illustrates floating pointround-off errors and demonstrates why it's a bad idea touse equal comparisons with floating point numbers.(2 examples please.)
2 pts Your C program programmatically demonstrates thatassociate order of arithmetic operations is important.(2 examples please.)
Data Types Lab