NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

double

The double keyword denotes a simple type that stores 64-bit floating-point values. The following table shows the precision and approximate range for the double type.

Type Approximate range Precision NGWS Type
double ±5.0 × 10-324 to ±1.7 × 10308 15-16 digits System.Double

Literals

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

double x = 3D;

Conversions

You can mix numeric integral types and floating-point types in an expression. In this case, the integral types are converted to floating-point types. The evaluation of the expression is performed according to the following rules:

A floating-point expression can contain the following sets of values:

For more information on these values, refer to IEEE Standard for Binary Floating-Point Arithmetic, available on the Web site http://www.ieee.org/.

For more information on floating-point value sets, see §4.1.5 in the language reference.

Example

In the following example, an int, a short, a float, and a double are added together giving a double result.

// Mixing types in expressions
using System;
class MixedTypes {
   public static void Main()  {
      int x = 3;
      float y = 4.5f;
      short z = 5;
      double w = 1.7E+3;
      Console.WriteLine("The sum is {0}", x+y+z+w);   // double result
   }
}

Output

The sum is 1712.5

See Also

C# Keywords | Default Values Table | Built-in Types Table | Floating-point Types Table | Implicit Numeric Conversions Table | Explicit Numeric Conversions Table