Computer Chess Club Archives


Search

Terms

Messages

Subject: Problem in manipulating time in mins & secs !

Author: Gopikrishna

Date: 00:45:39 07/21/04


Time is passed as double.I preffered double instead of unsigned long because for
outputting fraction of secs like 2.23 secs, double is more convenient.

  So ttm is passsed as double.
 if ((ttm/1000) >=60)
{
	ttm=ttm/1000;
             ms=ttm/60;
	ttm=(ttm-(ms1*60));
	min1=(int)ms1;
}
else
ttm=ttm/1000;

In the above ms is declared as double whereas min1 as int.
So when I print time as,
Printf("Total time:%d min:%2.2f secs",min1,ttm);

  So when time was passed as 61000 (or 61secs), its outputting as
Total time:0 min:-61.00 sec
Strange!!! Also another problem is its in minus.
It should have been 1 min:1 sec.So am i doing anything wrong in the above?
Actually I could have passed time as unsigned long instead of double but as you
can see I want that secs to be accurate like 2.23 secs instead of 2 secs !
  So please help me.Thanks.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.