Floating Point Variables


In this sub-section, I will be discussing with you the main floating point in C#, which is double and decimal. Floating points are in simple terms, the program trying to float in between integers so that you can go into decimals. Notice the word trying, the computer will be pretty dang precise, but, it won’t be 100% precise. You won’t notice the accuracy because it is that close, so don’t worry about it. In order to declare a double variable, you need to type, ‘Double dVari;’. This states the variable we will use and labels it.



To initialize this double variable, type this code under it. ‘dVari = 6.5;’.



This variable is almost the exact same as the previous variable, Int, except for the decimal part. So the Int example can be applyed to this as well.



You’ve just created a floating point variable, next we will be dealing with the last type of variable that we will be discussing for this guide, which is a string.