-
May 23rd, 2002, 11:12 AM
#1
Multiply Operator for a CTimeSpan object?
Sorry if this is a dumb question.
I have a CTimeSpan object that represents the period of time that I want an experiment to run. I then want to be able to run the experiment again for a factor * (CTimeSpan object).
Unfortunately there is no muliplication operator for CTimeSpan objects, so does anyone know a simple way to achieve the same goal ?, i.e. multiply a CTimeSpan by a float value.
As you have guessed I am a novice. Any help woudl be great.
WynW
-
May 23rd, 2002, 11:20 AM
#2
You have to do something like this:
Code:
int sec = timespan.GetTotalSeconds();
sec = (int)(sec * 10.5);
timespan = CTimeSpan((time_t)sec);
regards,
MiMec
-
May 23rd, 2002, 11:34 AM
#3
You could create your own operator like this:
CTimeSpan& operator *=(CTimeSpan& t, float n)
{
t = (time_t)(t.GetTotalSeconds() * n);
return t;
}
CTimeSpan t1(1,24,60,60);
t1 *= 2;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|