Académique Documents
Professionnel Documents
Culture Documents
1.1
LESSON
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
LESSON
1.1
Guiding Questions
1. 2.
How are program instructions stored in a computer? Identify the different data types that can be used and the values they can hold.
LESSON
1.1
Activator
Name the components of a computer. What components are involved in storing program instructions?
LESSON
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 performed on the values, and the way in which the values are stored in memory. Garbage collectiona process for automatic recovery of heap memory. Heapa 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. Stacka region of reserved memory in which programs store status data such as procedure and function call addresses, passed parameters, and sometimes local variables.
LESSON
1.1
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 semiconductor storage (RAM) directly connected to the processor. Secondary storageOtherwise known as a hard drive, it consists of a read/write head that floats above rotating platters coated with a magnetic material.
LESSON
1.1
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.
LESSON
1.1
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.
LESSON
1.1
Data Types
Numeric data types Integral types (e.g.: byte, char, int) Floating-point types (float, double) Decimal Boolean
LESSON
1.1
Data Types
Numeric data types Integral types (e.g.: byte, char, int) Floating-point types (float, double) Decimal Boolean
LESSON
1.1
Integral Types
Type sbyte byte char Range -128 to 127 0 to 255 U+0000 to U+ffff Size Signed 8-bit integer Unsigned 8-bit integer Unicode 16-bit character
short
ushort int uint long
-32,768 to 32,767
0 to 65,535 -2,147,483,648 to 2,147,483,647 0 to 4,294,967,295 -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
ulong
0 to 18,446,744,073,709,551,615
LESSON
1.1
Floating-Point Types
Type float double Approximate Range 1.5e45 to 3.4e38 5.0e324 to 1.7e308 Precision 7 digits 15-16 digits
LESSON
1.1
Decimal Type
Type decimal Approximate Range 1.0 1028 to 7.9 1028 Precision 28-29 significant digits
LESSON
1.1
LESSON
1.1
Lesson Review