Data Types, Variables, and Constants Integer Data Types
This document discusses integer data types in C#, including byte, short, int, and long which have different numbers of bits in memory. It notes that adding 1 to an int variable with a value of 1 will result in 2, while adding 1 to an int variable with a maximum value will overflow and result in the minimum int value. The document also distinguishes between value types and reference types before covering integer data types.
Data Types, Variables, and Constants Integer Data Types
This document discusses integer data types in C#, including byte, short, int, and long which have different numbers of bits in memory. It notes that adding 1 to an int variable with a value of 1 will result in 2, while adding 1 to an int variable with a maximum value will overflow and result in the minimum int value. The document also distinguishes between value types and reference types before covering integer data types.
In this lecture, well discuss the various data types we use to represent integers in C# Before we do, we make an important distinction between value types and reference types
Integers (no fractions or decimals) 0, 42, -11 byt e, shor t , i nt , l ong Different number of bits in memory for each type What does that tell us? Operations are mostly as youd expect (except for /) In-Lecture Quiz
In C#, if we add 1 to an i nt variable that currently has a value of 1, the new value of the variable is
A: 5 B: 12 C: 2 D: -0
In-Lecture Quiz
In C#, if we add 1 to an i nt variable that currently has a value of 2,147,483,647, the new value of the variable is
A: 2,147,483,648 B: -2,147,483,648 C: 42 D: 2
Recap For the value types, the contents of the memory location are interpreted as the value of the variable C# provides a variety of data types for representing integers Next Time Real numbers