Easy question: Decimals to time

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2007
Posts: 2
Reputation: japat is an unknown quantity at this point 
Solved Threads: 0
japat japat is offline Offline
Newbie Poster

Easy question: Decimals to time

 
0
  #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:
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 2
Reputation: japat is an unknown quantity at this point 
Solved Threads: 0
japat japat is offline Offline
Newbie Poster

Re: Easy question: Decimals to time

 
0
  #2
Mar 2nd, 2007
Ok i worked out the setfill(n) function, so i just need the other part
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,378
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1466
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Easy question: Decimals to time

 
0
  #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
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC