Click here to Skip to main content
14,297,880 members
Rate this:
Please Sign up or sign in to vote.
See more:
T_Minutes= 55
T_Micro= 338.

double TimeInMilliSeconds= (T_Hours*60*60*1000)+(T_Minutes*60*1000)+(T_Sec*1000)+T_Milli+(T_Micro/1000);
TimeInMilliSeconds= 17719471.388;

it displayed as 1.77195e+07 but i want to keep this format 17719471.388 to keep it easy readable.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You did not show us how the value is displayed (which function is used to print the value to a string or display). Depending on that you can define how floating point values are printed.

Most of these functions (besides C++ streams) use the printf[^] formatting. For floating point values the 'f' format should do what you want. Your example output looks like the 'g' or 'e' format has been used.

To get more significand digits, specify also the precision.
XamBEE 18-Dec-15 16:29pm
Result is:=1.77195e+07
Jochen Arndt 18-Dec-15 17:40pm
When using the stream << operator with a floating point value, it will use a default format.

If you want a different format it is up to you to set that format. You can do that by setting the stream format options or pass a string that has been formatted according to your needs.

The first is a common C++ stream operation and the second a common C printf operation or when using some kind of C++ string class the appropiate format function.

Overall these are basics that should be known by each C/C++ programmer (at least he should know how to obtain these information). The usage of streams and the usage of printf like functions are handled by any C++ resp. C tutorial.

This question is not especially Qt related but I know from your other questions that you are using it. I have used Qt first two years ago after 30 years of C programming experience and more than 15 years of C++. And I had really problems with Qt. The documentation often does not help and I used the Qt sources to find out what is really happening.

But you are obviously a beginner not only with Qt but with C/C++. So Qt is a really bad starting point. My suggestion is to learn at least the C/C++ basics before trying to write Qt applications.

I'm actually not able to express this in proper English (coming from the pub) but your profile shows that you are from Germany:
Entschuldige die harte Formulierung, aber ich denke, dass das wirklich nötig war.
nv3 18-Dec-15 18:24pm
My 5 - and you gave good general advice (even after visiting the pub).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100