Jump to: navigation, search

Description

The double type is a floating-point number data type. It has no unsigned equivalent.

A double is guaranteed to be at least 16 bits wide. Its characteristics in a given implementation are specified by macros provided in limits.h, as follows:

This list is incomplete. You can help clc-wiki by expanding it.

DBL_MIN is the minimum positive value that can be represented by a double. It must be positive, and no greater than 1E-37.

DBL_MAX is the greatest positive value that can be represented by a double. It must be at least 1E37.


Although the minimum required range and precision of double are the same as those for float, in practice it is typically much better. The very name double comes from the fact that an object of that type is intended to be a double-precision floating-point representation.

Floating-point literals are of type double by default. 3.14159 is a double, not a float.

The printf function uses the format specifier %f for a double. The following program defines a double, assigns a value to it, prints the value, and terminates.

#include <stdio.h>

int main(void)
{
  double d = 3.141592;
  printf("The value of d is %f\n", d);
  return 0;
}

The output of this program is:

The value of d is 3.141592

See also

float

long double

References

  • ISO C99 Standard, 6.2.5
Personal tools