00001 #ifndef CLASSLIB_BIT_TRAITS_H
00002 # define CLASSLIB_BIT_TRAITS_H
00003
00004
00005
00006 # include "classlib/sysapi/system.h"
00007 # include <climits>
00008
00009 namespace lat {
00010
00011
00012
00013
00014
00015
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
00043
00045 enum { HexDigits = Bits / 4 + ((Bits % 4) > 0) };
00046 };
00047
00048
00049
00050
00051 }
00052 #endif // CLASSLIB_BIT_TRAITS_H