// ============================================================ // // factorPowerOfTwo.h // // Copyright 2002, Dennis Meilicke and Rene Peralta // // ============================================================ // // Description: // // NTTL Implementation of: // FactorPowerOfTwo // // ============================================================ #ifndef __nttl_factorPowerOfTwo__ #define __nttl_factorPowerOfTwo__ #include template< class T, class T2 > T FactorPowerOfTwo( T A, T2 *e ) // // Description: // // Compute K s.t. A = K * 2^e ; Return K // { nttlTraits t; if( A == 0 ) { (*e) = 0; return A; } for( (*e)=0 ; t.IsEven( A ) ; (*e)++ ) A = (A >> 1); return A; } #endif