13,045,422 members (69,221 online)
Rate this:
See more:
Hi guys!
I am trying to create an array that stores 4 lap times, for example:
Double arrayName[4] = {1.40, 1.45, 1.32, 1.20};

Then I need to add all these figures together and produce a total, average, fastest etc.

My problem is, they are not calculated as time, but as floating point numbers. Is there a way I can format the time inside the array? Or even take the total figure (as a double) and convert it to a time format in minutes/seconds?

Owen
Posted 22-Apr-13 10:43am
Sergey Alexandrovich Kryukov 22-Apr-13 16:55pm

Makes no sense. Why "but"? What is "format"? What's the problem?
—SA
ryanb31 22-Apr-13 16:57pm

Usually time is just a number. It is often the number of seconds from a given fixed date and time. Assuming they are standard in .Net you can just format them as time and .Net will convert them.

Rate this:

## Solution 1

The app you are using is very badly formed (or if you wrote it, you should rewrite it).

Really the only way to do this properly is to convert the times to number of seconds (even if the elapsed time is years, weeks, days, hours, minutes or already seconds) and then you can do all the sum/average/other stats that you want. For the examples you posted here, it seems that to the left of the decimal point is minutes and to the right is seconds. If this is true, you want to multiply the int cast of each by 60 and add the fraction times 100, giving total seconds.

After doing this, perhaps shoot the guy that invented that format. It has inherent error for times of (say) 0.33 and even worse for subsecond times. This would not pass any professional timing tests.

Top Experts
Last 24hrsThis month
 OriginalGriff 248 Graeme_Grant 135 ppolymorphe 114 Atlapure Ambrish 80 kp564 70
 OriginalGriff 4,713 RickZeeland 1,854 ppolymorphe 1,708 F-ES Sitecore 1,553 Dave Kreskowiak 1,349