Upload
kartikrao31
View
234
Download
9
Embed Size (px)
Citation preview
8/3/2019 Soft Dev Fund PPT 1.1
1/15
Understand ComputerStorage and Data Types
98-361 Software Development Fundamentals
L E S S O N 1 . 1
8/3/2019 Soft Dev Fund PPT 1.1
2/15
98-361 Software Development Fundamentals
L E S S O N 1 . 1
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
8/3/2019 Soft Dev Fund PPT 1.1
3/15
98-361 Software Development Fundamentals
L E S S O N 1 . 1
Guiding Questions
1. How are program instructions stored in a computer?
2. Identify the different data types that can be used and the values theycan hold.
8/3/2019 Soft Dev Fund PPT 1.1
4/15
98-361 Software Development Fundamentals
L E S S O N 1 . 1
Activator
Name the components of a computer.
What components are involved in storing program instructions?
8/3/2019 Soft Dev Fund PPT 1.1
5/15
98-361 Software Development Fundamentals
L E S S O N 1 . 1
Review Terms Data typea definition of a set of data that specifies the possible
range of values of the set, the operations that can be performedon the values, and the way in which the values are stored inmemory.
Garbage collectiona process for automatic recovery of heapmemory.
Heapa portion of memory reserved for a program to use for thetemporary storage of data structures whose existence or sizecannot be determined until the program is running.
Memorya device where information can be stored andretrieved.
Stacka region of reserved memory in which programs storestatus data such as procedure and function call addresses, passedparameters, and sometimes local variables.
8/3/2019 Soft Dev Fund PPT 1.1
6/15
98-361 Software Development Fundamentals
L E S S O N 1 . 1
How a computer stores programs in memory
A computer keeps data and programs in storage as follows:
Primary storageOtherwise known as random access memory(RAM), it is made of memory chips. In common usage, it refers
only to a computers main memory, the fast semiconductorstorage (RAM) directly connected to the processor.
Secondary storageOtherwise known as a hard drive, itconsists of a read/write head that floats above rotating platterscoated with a magnetic material.
8/3/2019 Soft Dev Fund PPT 1.1
7/15
98-361 Software Development Fundamentals
L E S S O N 1 . 1
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 onthe heap.
The stack
Values in the stack are managed without garbage collectionbecause items are added and removed from the stack as last in,first out (LIFO) every time you enter or exit a scope, like amethod or statement
A StackOverFlowException occurs because you have usedup all the available space in the stack.
8/3/2019 Soft Dev Fund PPT 1.1
8/15
98-361 Software Development Fundamentals
L E S S O N 1 . 1
Memory
Stacks and Heaps (continued) The heap
A heap-based memory allocation occurs when we create a newobject, at which point the compiler figures out how much memory
is needed and allocates an appropriate amount of memory spaceand 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 upspace during run time.
Garbage collection is an automatic process for recovery of heapmemory. Blocks of memory that had been allocated but are nolonger in use are freed, and blocks of memory still in use may bemoved to consolidate the free memory into larger blocks.
8/3/2019 Soft Dev Fund PPT 1.1
9/15
98-361 Software Development Fundamentals
L E S S O N 1 . 1
Data Types Numeric data types
Integral types (e.g.: byte, char, int)
Floating-point types (float, double)
Decimal
Boolean
Example: bool done = false;
8/3/2019 Soft Dev Fund PPT 1.1
10/15
98-361 Software Development Fundamentals
L E S S O N 1 . 1
Data Types Numeric data types
Integral types (e.g.: byte, char, int)
Floating-point types (float, double)
Decimal
Boolean
bool done = false;
8/3/2019 Soft Dev Fund PPT 1.1
11/15
98-361 Software Development Fundamentals
L E S S O N 1 . 1
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,807Signed 64-bit integer
ulong 0 to 18,446,744,073,709,551,615 Unsigned 64-bit integer
8/3/2019 Soft Dev Fund PPT 1.1
12/15
98-361 Software Development Fundamentals
L E S S O N 1 . 1
Floating-Point Types
Type Approximate Range Precision
float 1.5e45 to 3.4e38 7 digits
double 5.0e324 to 1.7e308 15-16 digits
8/3/2019 Soft Dev Fund PPT 1.1
13/15
98-361 Software Development Fundamentals
L E S S O N 1 . 1
Decimal Type
Type Approximate Range Precision
decimal 1.0 1028 to 7.9 1028 28-29 significant digits
8/3/2019 Soft Dev Fund PPT 1.1
14/15
98-361 Software Development Fundamentals
L E S S O N 1 . 1
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;
8/3/2019 Soft Dev Fund PPT 1.1
15/15
98-361 Software Development Fundamentals
L E S S O N 1 . 1
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