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.

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

Slides created by: Professor Ian G. Harris Efficient C Code  Your C program is not exactly what is executed  Machine code is specific to each ucontroller.
Intro to Computer Systems Recitation #1 By sseshadr.
C Programming Day 1 based upon Practical C Programming by Steve Oualline CS550 Operating Systems.
Chapter 2 Representing and Manipulating Information Prof. Qi Tian CS 3843 Fall
CMPUT 101 Lab # 5 October 22, :00 – 17:00.
Assembly Language and Computer Architecture Using C++ and Java
1 Lecture 3 Bit Operations Floating Point – 32 bits or 64 bits 1.
1 CSC 1401 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
Assembly Language and Computer Architecture Using C++ and Java
More on Numerical Computation CS-2301 B-term More on Numerical Computation CS-2301, System Programming for Non-majors (Slides include materials from.
1 9/25/06CS150 Introduction to Computer Science 1 Nested Ifs, Logical Operators, exit() Page 194.
Data types and variables
More about Numerical Computation CS-2301, B-Term More about Numerical Computation CS-2301, System Programming for Non-Majors (Slides include materials.
Chapter 2 Data Types, Declarations, and Displays
+ CS 325: CS Hardware and Software Organization and Architecture Integers and Arithmetic Part 4.
Representation and Conversion of Numeric Types 4 We have seen multiple data types that C provides for numbers: int and double 4 What differences are there.
GTECH 731 Lab Session 2 Lab 1 Review, Lab 2 Intro 9/6/10 Lab 1 Review Lab 2 Overview.
01- Intro-Java-part1 1 Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology June 2008.
Objectives You should be able to describe: Data Types
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Georgia Institute of Technology Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology Aug 2005.
Computer Science 111 Fundamentals of Programming I Number Systems.
Computer Architecture
BYU CS 124Lab 0 - Warm-up Lab1 Lab 0 – Warm-up Lab 1.Acquire a Texas Instruments MSP430 LaunchPad Development Tool. 2.Setup a CS user account. 3.Install.
C Tokens Identifiers Keywords Constants Operators Special symbols.
Engineering Computing I Chapter 1 – Part A A Tutorial Introduction.
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
CIS-165 C++ Programming I CIS-165 C++ Programming I Bergen Community College Prof. Faisal Aljamal.
Introduction to C Programming Chapter 2 : Data Input, Processing and Output.
Exposure C++ Chapter VI Data Type Operations C++ Integer Operations Symbols +Addition -Subtraction *Multiplication /Integer division %Modulus or Remainder.
Syntax and Semantics, and the Program Development Process ROBERT REAVES.
CSCE 548 Integer Overflows Format String Problem.
CS115 FALL Senem KUMOVA-METİN1 The Fundamental Data Types CHAPTER 3.
Khalid Rasheed Shaikh Computer Programming Theory 1.
Introduction to computers 103 學年度 上學期 Solution of Homework_ch12 授課教授:李錫智.
Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11=
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Arithmetic OperatorOperationExample +additionx + y -subtractionx - y *multiplicationx * y /divisionx / y Mathematical FormulaC Expressions b 2 – 4acb *
11/10/2016CS150 Introduction to Computer Science 1 Last Time  We covered “for” loops.
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
C is a high level language (HLL)
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
1 Objects Types, Variables, and Constants Chapter 3.
ME 120: Arduino Programming Arduino Programming Part II ME 120 Mechanical and Materials Engineering Portland State University
Computer Engineering page 1 Integer arithmetic Depends what you mean by “integer”. Assume at 3-bit string. –Then we define: zero = 000 one = 001 Use zero,
Chapter 1 slides1 What is C? A high-level language that is extremely useful for engineering computations. A computer language that has endured for almost.
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
1 Binghamton University Exam 1 Review CS Binghamton University Birds eye view -- Topics Information Representation Bit-level manipulations Integer.
Secure Coding Rules for C++ Copyright © 2016 Curt Hill
Computer Science 210 Computer Organization
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.
INC 161 , CPE 100 Computer Programming
Chapter 4 – Fundamental Data Types
L7 – Assembler Directives
Administrative things
INTRODUCTION c is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs.
Roller Coaster Design Project
Conversions of the type of the value of an expression
توابع ورودي-خروجي.
Unit 2 Programming.
Introduction to CS Your First C Programs
Computer Science 210 Computer Organization
Basic Types Chapter 7 Copyright © 2008 W. W. Norton & Company.
INC 161 , CPE 100 Computer Programming
ECE 103 Engineering Programming Chapter 8 Data Types and Constants
Variables and Constants
Presentation transcript:

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." BYU CS 124 Lab 1 - Data Types

Data Types Lab Lab 1 – Data Types Acquire a Texas Instruments MSP430 LaunchPad Development Tool (R1.5). Change RXD,TXD from vertical to horizontal position. BYU CS 124 Lab 1 - Data Types

Data Types Lab Lab 1 – Data Types Install (if necessary) and execute TI's Code Composer Studio v5.x. BYU CS 124 Lab 1 - Data Types

Lab 1 – Data Types Open a Terminal window in CCS Data Types Lab BYU CS 124 Lab 1 - Data Types

Lab 1 – Data Types Compile and execute Lab01.c Data Types Lab BYU CS 124 Lab 1 - Data Types

Lab 1 – Data Types Level of printf/scanf support = full Data Types Lab BYU CS 124 Lab 1 - Data Types

TERMINAL Macros To output a string, use: TERMINAL(<string>); Data Types Lab TERMINAL Macros 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; BYU CS 124 Lab 1 - Data Types

Data Types Lab Lab 1 – Data Types 2 pts Your C program programmatically finds the largest values for signed and unsigned chars, ints, and longs and the most negative values for signed chars, ints, and longs. 2 pts Your C program programmatically demonstrates data type overflow for chars, ints, and longs. 2 pts Your C program programmatically finds the largest positive and most negative signed Q16.16 fixed point numbers. 2 pts Your C program programmatically illustrates floating point round-off errors and demonstrates why it's a bad idea to use equal comparisons with floating point numbers. (2 examples please.) 2 pts Your C program programmatically demonstrates that associate order of arithmetic operations is important. BYU CS 124 Lab 1 - Data Types