Hi everyone,

Please check my code below and tell me that why double stores number upto 3 decimal places ?

#include <iostream>

using namespace std;

int main()
{
    double dNo;
    dNo = 363.430965;

    cout<<"double no : " <<dNo <<endl;
    //cout only outputs dNo value upto 
    //3 decimal places

    return 0;
}

Actually i working on assignment in which i need to get number upto different decimal places say 3, 4 etc. But in above case it only store that number upto 3 decimal places and also rounds it off.

How can i store decimal number upto 5, 6 or greater decimal places in double ???

Kindly give me the solution and explain this issue in detail. Thanks !

Regards

Recommended Answers

All 3 Replies

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.