double (C++)

double is the C++ type for numbers with a decimal point, such as 3.14 or -0.5. It stores double-precision floating-point values and is the standard type for real numbers.

C++

Like floating-point numbers in any language, a double can't represent every decimal exactly, which can cause tiny rounding errors. There is also a smaller, less precise type called float.

When you divide two doubles, you get a decimal result rather than the truncated integer division you'd get with int.

Examples

C++

#include <iostream>

int main() {
    double a = 7.0;
    double b = 2.0;
    std::cout << a / b << std::endl;
    return 0;
}

Output:

3.5

Learn it in a lesson

See also

Back to the Dictionary