value of : (double) clock( ) / CLOCKS_PER_SEC 
Author Message
 value of : (double) clock( ) / CLOCKS_PER_SEC

In the following code, the final value of start is in milliseconds, right? I've
been getting some unexpected results. Thanks.

double start;
start = (double) clock( ) / CLOCKS_PER_SEC;
start = start/1000.0;

- Mark



Thu, 03 Aug 2000 03:00:00 GMT  
 value of : (double) clock( ) / CLOCKS_PER_SEC


Quote:
> In the following code, the final value of start is in milliseconds, right?
> I've been getting some unexpected results. Thanks.

> start = (double) clock( ) / CLOCKS_PER_SEC;

Err, no... did you miss that 'PER SEC' part of the macro? :)  'start' will
be in -seconds-, not milliseconds. :)

(Be sure to check for a return of -1 from clock().)

--
Attempting to write in a hybrid which can be compiled by either a C compiler
or a C++ compiler produces a compromise language which combines the drawbacks
of both with the advantages of neither.



Thu, 03 Aug 2000 03:00:00 GMT  
 value of : (double) clock( ) / CLOCKS_PER_SEC


Quote:

>In the following code, the final value of start is in milliseconds, right? I've
>been getting some unexpected results. Thanks.

>double start;
>start = (double) clock( ) / CLOCKS_PER_SEC;
>start = start/1000.0;

More like kiloseconds. But the important question is what results you
expected.

Ulric
--
You have committed Hungarian Heresey. You will be assimonylated.



Thu, 03 Aug 2000 03:00:00 GMT  
 value of : (double) clock( ) / CLOCKS_PER_SEC



Quote:

>In the following code, the final value of start is in milliseconds, right? I've
>been getting some unexpected results. Thanks.

>double start;
>start = (double) clock( ) / CLOCKS_PER_SEC;
>start = start/1000.0;

1 second is 1000 milliseconds so you need to multiply by 1000 to get a value
in millisecond units. Of course that doesn't imply that it will have
millisecond resolution.

--
-----------------------------------------


-----------------------------------------



Thu, 03 Aug 2000 03:00:00 GMT  
 value of : (double) clock( ) / CLOCKS_PER_SEC

[snip]

I can't believe I wrote that. Please ignore it.

--
Attempting to write in a hybrid which can be compiled by either a C compiler
or a C++ compiler produces a compromise language which combines the drawbacks
of both with the advantages of neither.



Thu, 03 Aug 2000 03:00:00 GMT  
 value of : (double) clock( ) / CLOCKS_PER_SEC

Quote:


> [snip]

> I can't believe I wrote that. Please ignore it.

I can't believe that you wrote that, so I'll ignore it :-)
Actually you comment was correct. The line you indicated did calculate
it in second, it's the following line (the one you snipped) that
was a bit funny (calculating kiloseconds).

Stephan
(initiator of the campaign against grumpiness in c.l.c)



Fri, 04 Aug 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. CLOCKS_PER_SEC value

2. addition long values to long double value ?

3. inconsistent return values from clock()

4. return value of clock() function

5. Counting the clock... (counting clock cycles)

6. An employee clock-in/clock-out program

7. Q: update system clock with real time clock

8. clock() function and CPU/wall clock time

9. Sorting on double values.

10. CLOCKS_PER_SEC

11. question about huge double value

12. Largest double value ...

 

 
Powered by phpBB® Forum Software