double (C++)

From Just Solve the File Format Problem
Jump to: navigation, search
File Format
Name double (C++)
Ontology
Released 1983


C++ double is the default floating point data type. Unlike many other languages C++ doesn't use float as the default floating point. The name is somewhat misleading, because double is not guaranteed by standards to provide twice the precision of float nor to take twice as many bytes of memory for storage. The standard defines double as having not less precision than float, which is a common theme in C++ standards.

It is not possible to enumerate double values, and thus it cannot be used in constructs like switch.

Literals

Literals with a floating point or exponent are double. For example: 1.5, .3, 5e-7

Double can store positive infinity, negative infinity, and NaN (not a number). NaN is generated when the result is mathematically ambiguous or impossible to determine, for example 0รท0.

Characteristics

The <cfloat> library consists of the following constants describing the behaviour of float

  • FLT_RADIX — base of the floating point numbers.
  • DBL_MANT_DIG — number of mantissa digits.
  • DBL_DIG — number of significant digits that can be stored.
  • DBL_MIN_EXP — minimum negative exponent.
  • DBL_MAX_EXP — maximum positive exponent.
  • DBL_MIN_10_EXP — minimum base-10 negative exponent that can be transformed into a valid double
  • DBL_MAX_10_EXP — maximum base-10 positive exponent that can be transformed into a valid double
  • DBL_EPSILON — the difference from 1.0 to the smallest possible value that is greater than 1.0
  • DBL_MIN — the smallest possible value that is greater than 0.0

Other C++ data types storing floating point numbers

  • float least precise floating point data type
  • long double not less precise than double
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox