tags:

views:

48

answers:

2
typedef LONGLONG REFERENCE_TIME;

I want to convert double Time to REFERENCE_TIME Time, how to do it?

A: 

Assuming LONGLONG is just a typedef for a built in type, you can try:

REFERENCE_TIME rt = static_cast<REFERENCE_TIME>(Time);

But, it would be safer to use boost::numeric_cast

http://www.boost.org/doc/libs/1_44_0/libs/numeric/conversion/doc/html/boost_numericconversion/improved_numeric_cast__.html

Mark
+1  A: 

Reference time is absed on a 100ns clock. That means there are 10,000,000 ticks a second.

So assuming your double is in seconds then you need to do

REFERENCE_TIME rt = static_cast< REFERENCE_TIME >( doubleTime * 10000000.0 );
Goz