NTTL - nttlTraits

Description
The traits class is a concept borrowed from the STL.  The idea is that sometimes you need to know something about the type passed to a template.  The traits class provides a mechanism for this.
NTTL Traits
In NTTL, the traits class is not used so much as a means to learn about the underlying type, but more as a means of determining the most efficient way to do something for a particular type.  For example, in many large integer implementations, squaring can be done more efficiently than multiplying.  In the implementation of an NTTL function, then, we should never include multiplication:
y = x * x;
when we really mean squaring:
y = x.Square( );
But x.Square( ) is not implemented for the PODs, and may have a different syntax for some large integer packages.  So instead, we use a member function of the traits class:
template<class T>
T
someNttlFunction( T x, T y )
{
    nttlTraits<T> trts;
    ....
    z = trts.Square( x );
}
Guidelines
When adding a new method to the NTTL traits class, it is important to provide a default implementation that is as generic as possible.  One of the design goals of NTTL is that it should be usable with any type, without modification.  The specializations of the traits class provide extra efficiency only.  No algorithm should require a specialization of the traits class before it will work (exceptions: iterators?  This is really not an exception.  The right-to-left algorithms can be implemented in terms of right shift operations, which should be defined for any integer type.  The left-to-right algorithms, and the windowing algorithms, will require the implementation of an iterator.  But these algorithms are just more efficient versions of the right-to-left binary algorithms.  So we really aren't breaking the rules.  An algorithm is available, without specializing the package in any way.  In order to get the most efficient algorithm, it may be necessary to specialize...).
Declaration
The following is the declaration of the nttlTraits class.  Documentation for the particular methods is available by clicking the method name.
template< class T >
class nttlTraits
{
public:
    T              Random( size_t digits );
    T              RandomMod( T m );
    T              Square( const T& x );
    short          Mod4( const T& x );
    short          Mod8( const T& x );
    bool           IsOdd( const T &x );
    bool           IsEven( const T &x );
    T              Abs( const T &X );
    T              Power( T X, T e );
    T              Power( T X, T e, const T &m );
    size_t         DecimalDigits( const T& x );
    short          ToShort( const T& X );
    long           ToLong( const T& X );
    unsigned short ToUnsignedShort( const T& X );
    unsigned long  ToUnsignedLong( const T& X );
};