本文整理汇总了C++中CDateTime::MSec方法的典型用法代码示例。如果您正苦于以下问题:C++ CDateTime::MSec方法的具体用法?C++ CDateTime::MSec怎么用?C++ CDateTime::MSec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDateTime
的用法示例。
在下文中一共展示了CDateTime::MSec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AutoSetRNGSeeds
// Automatically generate unique RNG seeds.
// The CRandom class uses an unsigned 64-bit value for the seed.
// This routine automatically generates two unique seeds. One is used for
// the TxnInput generator RNG, and the other is for the TxnMixGenerator RNG.
// The 64 bits are used as follows.
//
// Bits 0 - 31 Caller provided unique unsigned 32-bit id.
// Bit 32 0 for TxnInputGenerator, 1 for TxnMixGenerator
// Bits 33 - 43 Number of days since the base time. The base time
// is set to be January 1 of the most recent year that is
// a multiple of 5. This allows enough space for the last
// field, and it makes the algorithm "timeless" by resetting
// the generated values every 5 years.
// Bits 44 - 63 Current time of day measured in 1/10's of a second.
//
void CMEE::AutoSetRNGSeeds( UINT32 UniqueId )
{
CDateTime Now;
INT32 BaseYear;
INT32 Tmp1, Tmp2;
Now.GetYMD( &BaseYear, &Tmp1, &Tmp2 );
// Set the base year to be the most recent year that was a multiple of 5.
BaseYear -= ( BaseYear % 5 );
CDateTime Base( BaseYear, 1, 1 ); // January 1st in the BaseYear
// Initialize the seed with the current time of day measured in 1/10's of a second.
// This will use up to 20 bits.
RNGSEED Seed;
Seed = Now.MSec() / 100;
// Now add in the number of days since the base time.
// The number of days in the 5 year period requires 11 bits.
// So shift up by that much to make room in the "lower" bits.
Seed <<= 11;
Seed += (RNGSEED)((INT64)Now.DayNo() - (INT64)Base.DayNo());
// So far, we've used up 31 bits.
// Save the "last" bit of the "upper" 32 for the RNG id.
// In addition, make room for the caller's 32-bit unique id.
// So shift a total of 33 bits.
Seed <<= 33;
// Now the "upper" 32-bits have been set with a value for RNG 0.
// Add in the sponsor's unique id for the "lower" 32-bits.
Seed += UniqueId;
// Set the Ticker Tape RNG to the unique seed.
m_TickerTape.SetRNGSeed( Seed );
m_DriverMEESettings.cur.TickerTapeRNGSeed = Seed;
// Set the RNG Id to 1 for the Trading Floor.
Seed |= UINT64_CONST(0x0000000100000000);
m_TradingFloor.SetRNGSeed( Seed );
m_DriverMEESettings.cur.TradingFloorRNGSeed = Seed;
}
示例2: AutoSetRNGSeeds
// Automatically generate unique RNG seeds.
// The CRandom class uses an unsigned 64-bit value for the seed.
// This routine automatically generates two unique seeds. One is used for
// the TxnInput generator RNG, and the other is for the TxnMixGenerator RNG.
// The 64 bits are used as follows.
//
// Bits 0 - 31 Caller provided unique unsigned 32-bit id.
// Bit 32 0
// Bits 33 - 43 Number of days since the base time. The base time
// is set to be January 1 of the most recent year that is
// a multiple of 5. This allows enough space for the last
// field, and it makes the algorithm "timeless" by resetting
// the generated values every 5 years.
// Bits 44 - 63 Current time of day measured in 1/10's of a second.
//
void CDM::AutoSetRNGSeeds( UINT32 UniqueId )
{
CDateTime Now;
INT32 BaseYear;
INT32 Tmp1, Tmp2;
Now.GetYMD( &BaseYear, &Tmp1, &Tmp2 );
// Set the base year to be the most recent year that was a multiple of 5.
BaseYear -= ( BaseYear % 5 );
CDateTime Base( BaseYear, 1, 1 ); // January 1st in the BaseYear
// Initialize the seed with the current time of day measured in 1/10's of a second.
// This will use up to 20 bits.
RNGSEED Seed;
Seed = Now.MSec() / 100;
// Now add in the number of days since the base time.
// The number of days in the 5 year period requires 11 bits.
// So shift up by that much to make room in the "lower" bits.
Seed <<= 11;
Seed += Now.DayNo() - Base.DayNo();
// So far, we've used up 31 bits.
// Save the "last" bit of the "upper" 32 for the RNG id. In
// this case, it is always 0 since we don't have a second
// RNG in this class.
// In addition, make room for the caller's 32-bit unique id.
// So shift a total of 33 bits.
Seed <<= 33;
// Now the "upper" 32-bits have been set with a value for RNG 0.
// Add in the sponsor's unique id for the "lower" 32-bits.
Seed += UniqueId;
// Set the RNG to the unique seed.
m_rnd.SetSeed( Seed );
m_DriverDMSettings.cur.RNGSeed = Seed;
}