User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 375,170 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,210 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 666 | Replies: 2
Reply
Join Date: Mar 2007
Posts: 2
Reputation: japat is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
japat japat is offline Offline
Newbie Poster

Easy question: Decimals to time

  #1  
Mar 2nd, 2007
I am using c++ and would like to know the easiest way to turn decimals in to the form hours:minutes:seconds.

You can assume the integer is in the form of hours (e.g. 242.4 = 242 hours 24 seconds etc)

Also, I would like it so that seconds is to one decimal place, and that if a field is blank it will show up like this 00:00:00.0

Thanks heaps :mrgreen:
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2007
Posts: 2
Reputation: japat is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
japat japat is offline Offline
Newbie Poster

Re: Easy question: Decimals to time

  #2  
Mar 2nd, 2007
Ok i worked out the setfill(n) function, so i just need the other part
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,199
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 34
Solved Threads: 824
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: Easy question: Decimals to time

  #3  
Mar 2nd, 2007
modf() will help you split a floating point number into its integer and fractional parts. see man pages for more details8
'Politics' is made up of two words, 'poli,' which is Greek for 'many,' and 'tics,' which are blood-sucking insects.
- Gore Vidal
Being ignorant is not so much a shame as being unwilling to learn. - Benjamin Franklin
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 11:48 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC