CMS 3D CMS Logo

BitTraits.h

Go to the documentation of this file.
00001 #ifndef CLASSLIB_BIT_TRAITS_H
00002 # define CLASSLIB_BIT_TRAITS_H
00003 
00004 //<<<<<< INCLUDES                                                       >>>>>>
00005 
00006 # include "classlib/sysapi/system.h"
00007 # include <climits>
00008 
00009 namespace lat {
00010 //<<<<<< PUBLIC DEFINES                                                 >>>>>>
00011 //<<<<<< PUBLIC CONSTANTS                                               >>>>>>
00012 //<<<<<< PUBLIC TYPES                                                   >>>>>>
00013 //<<<<<< PUBLIC VARIABLES                                               >>>>>>
00014 //<<<<<< PUBLIC FUNCTIONS                                               >>>>>>
00015 //<<<<<< CLASS DECLARATIONS                                             >>>>>>
00016 
00031 template <class T>
00032 struct BitTraits
00033 {
00035     enum { Bits         = sizeof (T) * CHAR_BIT };
00036 
00038     enum { Bytes        = Bits / 8 + ((Bits % 8) > 0) };
00039 
00041     enum { Digits       = (Bits * 30103) / 100000 + 1 };
00042     // 30103 =~ M_LN2 / M_LN10 * 100000
00043 
00045     enum { HexDigits    = Bits / 4 + ((Bits % 4) > 0) };
00046 };
00047 
00048 //<<<<<< INLINE PUBLIC FUNCTIONS                                        >>>>>>
00049 //<<<<<< INLINE MEMBER FUNCTIONS                                        >>>>>>
00050 
00051 } // namespace lat
00052 #endif // CLASSLIB_BIT_TRAITS_H

Generated on Tue Jun 9 17:38:54 2009 for CMSSW by  doxygen 1.5.4