Search This Blog

Thursday, December 27, 2012

double (C#)

C# > Types > Double






Double type stores 64-bit floating-point values.

range: ±5.0 × 10−324 to ±1.7 × 10308
precision: 15-16 digits

By default, a real numeric literal on the right side of the assignment operator is treated as double, but if you want an integer number to be treated as double, use the suffix d or D.

double x = 10D;


Integral types and floating-point types can be mixed in an expression:

  • If one type is double the expression evaluates to double
  • If no double type in the expression it evaluates to float
Example: the sum is double type


int x = 1;
float y = 2.5f;
double w = 1.2E+1;
MessageBox.Show ("The sum is: " + (x + y +  w).ToString());