Monday, September 10, 2012

Data Types and Operators in C#


C#  Datatypes : 


 
Diff Between float and double in c# :

Integers, are whole numbers. They can't store the point something, like .7, .42, and .007. If you need to store numbers that are not whole numbers, you need a different type of variable. You can use the double type, or the float type. You set these types of variables up in exactly the same way: instead of using the word int, you type double, or float. Like this:


float myFloat;
double myDouble;


(Float is short for "floating point", and just means a number with a point something on the end.)
The difference between the two is in the size of the numbers that they can hold. For float, you can have up to 7 digits in your number. For doubles, you can have up to 16 digits. To be more precise, here's the official size:


float: 1.5 × 10-45 to 3.4 × 1038
double: 5.0 × 10-324 to 1.7 × 10308



 = > Float is a 32-bit number and double is a 64-bit number.
static void Main(string[] args)
        {
            float a = 100.123456789F;
            double d = 100.123456789;
            Console.WriteLine("Float value :" + a);
            Console.WriteLine("doulble value :" + d);
            Console.Read();
        }
The number of digits that a variable can hold is known as precision. For float variable, C# is precise to 7 digits: anything more and the number is rounded off.

C# operators List :



2 comments: