Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter One Lesson Three DATA TYPES © www.waxkabaro.com.

Similar presentations


Presentation on theme: "Chapter One Lesson Three DATA TYPES © www.waxkabaro.com."— Presentation transcript:

1 Chapter One Lesson Three DATA TYPES © www.waxkabaro.com

2 What is Data type? Data types are sets (ranges) of values that have similar characteristics. For instance byte type specifies the set of integers in the range of [0 … 255]. © www.waxkabaro.com

3 Types Basic data types in C# are distributed into the following types:  - Integer types (Whole Number without Negative) – short(int16), int(int32) long(int64);  - Real floating-point types(Decimal number with or without negative and ) – float, double;  - Real type with decimal precision – decimal;  - Boolean type – bool (True or False);  - Character type – char;  - String – string;  - Object type – object. © www.waxkabaro.com

4 Integer types- examples { Int16 centuries = 20; Int16 years = 2000; Int32 days = 730480; Int32 hours = 17531520; Int32 minutes =1051891200; Int64 seconds = 63113472000; Int64 milliseconds = 3786808320000; Console.WriteLine(centuries + " centuries are " + years +" years, or " + days + " days, or " + hours + " hours or " + minutes + " minutes or " + seconds +" seconds or " + milliseconds + " millisoconds "); Console.ReadLine(); } © www.waxkabaro.com

5 Double Types Double and Decimal types are used for numbers with decimal numbers and negative number Double: It is also called double precision real number and is a 64-bit type with a default value of 0.0d and 0.0D (the suffix 'd' is not mandatory because by default all real numbers in C# are of type double). © www.waxkabaro.com

6 This type has precision of 15 to 16 decimal digits. The range of values, which can be recorded in double (rounded with precision of 15-16 significant decimal digits), © www.waxkabaro.com

7 Decimal type The type of data for real numbers with decimal precision in C# is the 128-bit type decimal. It has a precision from 28 to 29 decimal places. © www.waxkabaro.com

8 Example – Double Vs Decimal static void Main(string[] args) { int a = 1; int b = 2; decimal PI = 3.142857142857143m; double pi = 3.142857142857143; Console.WriteLine(PI); Console.WriteLine(pi); Console.ReadLine(); } © www.waxkabaro.com

9 Next Lesson Boolean Type © www.waxkabaro.com


Download ppt "Chapter One Lesson Three DATA TYPES © www.waxkabaro.com."

Similar presentations


Ads by Google