![]() |
| ||
| double data type When i use a variable type double the value e.g 345624.769123 rounded to 345625 but when i take 5 digits before decimal i.e 34562.4769123 then it shows 34562.5 Please explain Why? Thanks |
| ||
| Re: double data type Quote:
|
| ||
| Re: double data type Quote:
#include <conio.h> using std::cout; using std::cin; main() { double x=345624.769123; cout<<"x="; cout << x; getch(); } |
| ||
| Re: double data type The 5 digits before have nothing to do with it. When your system is rounding to tenths then xxxx.47.. is rounded to xxxx.5 just as xxxxxx.79.. is rounded to xxxxxx+1. Read also : http://en.wikipedia.org/wiki/Rounding |
| ||
| Re: double data type It's simply default precision of stream output. Don't worry, double type always keeps ~16 significant digits... Use setprecision manipulator from <iomanip> to set another output precision: #include <iomanip>Try this and see what happens... |
| All times are GMT -4. The time now is 12:32 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC