# double (C# Reference)

The `double`

keyword signifies 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 | .NET type |
---|---|---|---|

`double` |
±5.0 × 10^{−324} to ±1.7 × 10^{308} |
~15-17 digits | System.Double |

## Literals

By default, a real numeric literal on the right 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:

If one of the floating-point types is

`double`

, the expression evaluates to`double`

, or to bool in relational comparisons and comparisons for equality.If there is no

`double`

type in the expression, it evaluates to float, or to bool in relational comparisons and comparisons for equality.

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

Positive and negative zero.

Positive and negative infinity.

Not-a-Number value (NaN).

The finite set of nonzero values.

For more information about these values, see IEEE Standard for Binary Floating-Point Arithmetic, available on the IEEE Web site.

## 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
class MixedTypes
{
static void Main()
{
int x = 3;
float y = 4.5f;
short z = 5;
double w = 1.7E+3;
// Result of the 2nd argument is a double:
Console.WriteLine("The sum is {0}", x + y + z + w);
}
}
// Output: The sum is 1712.5
```

## C# language specification

For more information, see the C# Language Specification. The language specification is the definitive source for C# syntax and usage.

## See also

## Feedback

Send feedback about:

Loading feedback...