| | |
double data type
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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
Read also : http://en.wikipedia.org/wiki/Rounding
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
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:
Try this and see what happens...
Use setprecision manipulator from <iomanip> to set another output precision:
C++ Syntax (Toggle Plain Text)
#include <iomanip> double x = ......; ... for (int n = 0; n < 17; ++n) cout << setprecision(n) << x << endl;
Last edited by ArkM; Nov 9th, 2008 at 3:52 pm.
![]() |
Similar Threads
- C++: problam with data type(int,float,double) (C++)
- Range of a double integer in C++ (C++)
- Combined data type arrays. (C++)
- C double data type emulation library (C)
- why is double data type giving an garbage value (Java)
- Help With Data-type Declaration Symbols (Pascal and Delphi)
- C++ Data Types (C++)
- Data Abstraction (Computer Science)
Other Threads in the C++ Forum
- Previous Thread: Clock tick
- Next Thread: Problem with constructor
Views: 1013 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






