double

Type Range Default Value
double -1.79769313486232e308 to 1.79769313486232e308 0

The double type represents a double-precision floating-point number based on the IEEE-754 standard.

Literals

Integrals without a suffix are interpreted in this order: int, unsigned int, long, unsigned long, byte, signed byte, short, unsigned short, and char.

In order to denote a integral value as a double, it is necessary to use a suffix. The suffixes for the double type are D and d. Decimal values are, by default, treated as `double`.

Auto-boxing

All primitive types have a corresponding wrapper class. The corresponding wrapper class for the double type is System.Double.

Auto-boxing occurs when a value of a primitive type is assigned or passed as an argument to a variable or function that expects a value of its corresponding wrapper class. For example, the numeric value 1.1d is interpreted as double and can be assigned to a variable of type System.Double via auto-boxing:

1
System.Double value = 1.1d; // Auto-boxing

Without auto-boxing, the equivalent code would be:

1
System.Double value = new System.Double(1.1d);

The reverse also occurs. Unboxing is when the wrapper class is automatically converted to its corresponding primitive type. Thus, an instance of System.Double can be unboxed to the double primitive type.

1
double value = new System.Double(1.1d); // Unboxing

Conversions

For conversions to and from the double type, consult the Conversions Table.

See Also

Share

HTML | BBCode | Direct Link