Understand Computer Storage and Data Types

Similar documents
Chapter 2: Using Data

Visual C# Instructor s Manual Table of Contents

5 When a program calls a function, in which type of data structure is memory allocated for the variables in that function?

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Lesson 02 Working with Data Types. MIT 31043: VISUAL PROGRAMMING By: S. Sabraz Nawaz Senior Lecturer in MIT

Question And Answer.

Basic data types. Building blocks of computation

Lesson 02 Working with Data Types MIT 31043, Visual Programming By: S. Sabraz Nawaz

Advanced Computer Programming

VARIABLES AND TYPES CITS1001

Chapter 1 Getting Started

10/9/2012. Computers are machines that process data. assignment in C# Primitive Data Types. Creating and Running Your First C# Program

DAD Lab. 1 Introduc7on to C#

Appendix G: Writing Managed C++ Code for the.net Framework

C#: framework overview and in-the-small features

C# MOCK TEST C# MOCK TEST I

Bit (0, 1) Byte (8 bits: 0-255) Numeral systems. Binary (bin) 0,1 Decimal (dec) 0, 1, 2, 3, Hexadecimal (hex) 0, 1, 2, 3, 1/13/2011

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types

.Net Technologies. Components of.net Framework

Introduce C# as Object Oriented programming language. Explain, tokens,

The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:

a data type is Types

CS242 COMPUTER PROGRAMMING

C# Types. Industrial Programming. Value Types. Signed and Unsigned. Lecture 3: C# Fundamentals

Java Identifiers, Data Types & Variables

An Introduction to Processing

Industrial Programming

Overview. Arrays and their properties Creating arrays Accessing array elements Modifying array elements Loops and arrays. Initialization Searching

Computational Expression

IT 1033: Fundamentals of Programming Data types & variables

The type of all data used in a C (or C++) program must be specified

Brief introduction about memory queue -- CUQueue and CScopeUQueue objects

C# Fundamentals. Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh

C# INTRODUCTION. Object. Car. data. red. moves. action C# PROGRAMMERS GUIDE LESSON 1. CsGuideL1.doc. Date Started: May 8,2001

Lab # 02. Basic Elements of C++ _ Part1

The type of all data used in a C++ program must be specified

Java Basic Datatypees

Week 3 Lecture 2. Types Constants and Variables

Java Classes & Primitive Types

C Introduction. Comparison w/ Java, Memory Model, and Pointers

Exercise: Using Numbers

Compiling Techniques

Object-Oriented Programming. Topic 2: Fundamental Programming Structures in Java

Java Classes & Primitive Types

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

CHAPTER 5 VARIABLES AND OTHER BASIC ELEMENTS IN JAVA PROGRAMS

Introduction to C# Applications

Motivation was to facilitate development of systems software, especially OS development.

Primitive Types. Four integer types: Two floating-point types: One character type: One boolean type: byte short int (most common) long

CS313D: ADVANCED PROGRAMMING LANGUAGE

Computers and Programming Section 450. Lab #1 C# Basic. Student ID Name Signature

Defining Unified CCX CTI Messages

Introduction. Primitive Data Types: Integer. Primitive Data Types. ICOM 4036 Programming Languages

C# Fundamentals. built in data types. built in data types. C# is a strongly typed language

lesson 3 Transforming Data into Information

1.1 Bits and Bit Patterns. Boolean Operations. Figure 2.1 CPU and main memory connected via a bus. CS11102 Introduction to Computer Science

1.3b Type Conversion

Darshan Institute of Engineering & Technology for Diploma Studies

[0569] p 0318 garbage

Exercise: Inventing Language

Computer Science 50: Introduction to Computer Science I Harvard College Fall Quiz 0 Solutions. Answers other than the below may be possible.

Getting started with Java

C#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations

What goes inside when you declare a variable?

Motivation was to facilitate development of systems software, especially OS development.

Variables and Java vs C++

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

Chapter 2. Procedural Programming

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Zheng-Liang Lu Java Programming 45 / 79

COMP Primitive and Class Types. Yi Hong May 14, 2015

Oct. 3 fixup - Here are notes and codes in the proper order that they should be.

Types, Variables, and Constants

Data Types & Variables

Review for COSC 120 8/31/2017. Review for COSC 120 Computer Systems. Review for COSC 120 Computer Structure

1 class Lecture2 { 2 3 "Elementray Programming" / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch.

CSC Java Programming, Fall Java Data Types and Control Constructs

BTE2313. Chapter 2: Introduction to C++ Programming

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309

Murach s Visual Basic 2012, C4 2013, Mike Murach & Associates, Inc. Slide 1. The built-in value types (continued)

Integer Data Types. Data Type. Data Types. int, short int, long int

CUDA. Schedule API. Language extensions. nvcc. Function type qualifiers (1) CUDA compiler to handle the standard C extensions.

Chapter 3 Structured Program Development in C Part II

CSc Introduction to Computing

COMP322 - Introduction to C++ Lecture 01 - Introduction

Unit 4. Lesson 4.1. Managing Data. Data types. Introduction. Data type. Visual Basic 2008 Data types

Chapter 3. Section 3.10 Type of Expressions and Automatic Conversion. CS 50 Hathairat Rattanasook

Variables and Functions. ROBOTC Software

11 'e' 'x' 'e' 'm' 'p' 'l' 'i' 'f' 'i' 'e' 'd' bool equal(const unsigned char pstr[], const char *cstr) {

CS201- Introduction to Programming Current Quizzes

CMSC 313 Spring 2010 Exam 3 May 17, 2010

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

C++ Data Types. 1 Simple C++ Data Types 2. 3 Numeric Types Integers (whole numbers) Decimal Numbers... 5

Lecture 2 Tao Wang 1

Data Types. Data Types. Integer Types. Signed Integers

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program

Programmazione Avanzata

Transcription:

Understand Computer Storage and Data Types

Lesson Overview Students will understand computer storage and data types. In this lesson, you will learn: How a computer stores programs and instructions in computer memory Memory stacks and heaps Memory size requirements for the various data storage types Numeric data and textual data

Guiding Questions 1. How are program instructions stored in a computer? 2. Identify the different data types that can be used and the values they can hold.

Activator Name the components of a computer. What components are involved in storing program instructions?

Review Terms Data type a definition of a set of data that specifies the possible range of values of the set, the operations that can be performed on the values, and the way in which the values are stored in memory. Garbage collection a process for automatic recovery of heap memory. Heap a portion of memory reserved for a program to use for the temporary storage of data structures whose existence or size cannot be determined until the program is running. Memory a device where information can be stored and retrieved. Stack a region of reserved memory in which programs store status data such as procedure and function call addresses, passed parameters, and sometimes local variables.

How a computer stores programs in memory A computer keeps data and programs in storage as follows: Primary storage Otherwise known as random access memory (RAM), it is made of memory chips. In common usage, it refers only to a computer s main memory, the fast semiconductor storage (RAM) directly connected to the processor. Secondary storage Otherwise known as a hard drive, it consists of a read/write head that floats above rotating platters coated with a magnetic material.

Memory Stacks and Heaps Variables are stored in either a stack or heap based on their type: Value types (e.g.: int, double, float) go on the stack. Reference types (String, Object) go on the heap. * Value types in classes are stored with the instance of the class on the heap. The stack Values in the stack are managed without garbage collection because items are added and removed from the stack as last in, first out (LIFO) every time you enter or exit a scope, like a method or statement A StackOverFlowException occurs because you have used up all the available space in the stack.

Memory Stacks and Heaps (continued) The heap A heap-based memory allocation occurs when we create a new object, at which point the compiler figures out how much memory is needed and allocates an appropriate amount of memory space and returns a reference representing the memory address. A heap is used for dynamic allocation of memory. The Microsoft.NET Framework uses garbage collection to free up space during run time. Garbage collection is an automatic process for recovery of heap memory. Blocks of memory that had been allocated but are no longer in use are freed, and blocks of memory still in use may be moved to consolidate the free memory into larger blocks.

Data Types Numeric data types Integral types (e.g.: byte, char, int) Floating-point types (float, double) Decimal Boolean Example: bool done = false;

Data Types Numeric data types Integral types (e.g.: byte, char, int) Floating-point types (float, double) Decimal Boolean bool done = false;

Integral Types Type Range Size sbyte -128 to 127 Signed 8-bit integer byte 0 to 255 Unsigned 8-bit integer char U+0000 to U+ffff Unicode 16-bit character short -32,768 to 32,767 Signed 16-bit integer ushort 0 to 65,535 Unsigned 16-bit integer int -2,147,483,648 to 2,147,483,647 Signed 32-bit integer uint 0 to 4,294,967,295 Unsigned 32-bit integer long -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 Signed 64-bit integer ulong 0 to 18,446,744,073,709,551,615 Unsigned 64-bit integer

Floating-Point Types Type Approximate Range Precision float ±1.5e 45 to ±3.4e38 7 digits double ±5.0e 324 to ±1.7e308 15-16 digits

Decimal Type Type Approximate Range Precision decimal ±1.0 10 28 to ±7.9 10 28 28-29 significant digits

Using the Numeric Data Types byte numkids = 15; char letter = p ; int worldpopulation = 6692030277; float money = 201.00f; double lotsamoney = 2.4E+12; decimal testgrade = 89.5m;

Lesson Review Describe how the program statement below is stored in memory: int tennispoints = 30; Identify the appropriate data types for each of the following values. 4233423.93 100-2323 true