C++ Floating-Point Types

Introduction

There are three floating-point types in C++: float, double, long double.

We use them for storing floating-point values / real numbers:

#include <iostream> 

int main() /*from w ww.ja  v  a2  s.  co  m*/
{ 
    double d = 3.14; 
    std::cout << "The value of d is: " << d; 
} 

Some of the floating-point literals can be:

int main() 
{ 
    double x = 213.456; 
    double y = 1.; 
    double z = 0.15; 
    double w = .15; 
    double d = 3.14e10; 
} 



PreviousNext

Related