00001 00002 // 00003 // HexavigesimalConverter.h 00004 // 00005 // Yes, I know! The name of this class 00006 // is totally ridiculous! 00007 // 00008 // (c) 2009 by Edward H. Trager 00009 // 00010 // Released under the GNU General Public License. 00011 // A copy of the GPL is included in the distribution 00012 // package of this software, or see: 00013 // 00014 // http://www.gnu.org/copyleft/ 00015 // 00016 // ... for licensing details. 00017 // 00019 // 00020 // 2009.08.31.ET 00021 // 00022 #ifndef HEXAVIGESIMAL_CONVERTER 00023 #define HEXAVIGESIMAL_CONVERTER 00024 00025 // 00026 // HexavigesimalConverter 00027 // 00028 class HexavigesimalConverter{ 00029 00030 private: 00031 00032 // 00033 // 26 letters in the alphabet 00034 // gives the base for the numeral system: 00035 // 00036 static const int _base=26; 00037 00038 // 00039 // With the buffer size set to 8, 00040 // we can display up to 26^7 = 00041 // 8,031,810,176 -- that should be 00042 // big enough: 00043 // 00044 static const int _BUFSIZE=8; 00045 char _buffer[ _BUFSIZE ]; 00046 00047 // 00048 // Bijective switch: 00049 // 00050 bool _bijective; 00051 00052 public: 00053 // 00054 // Constructor: 00055 // 00056 // We set bijective to TRUE because this is the 00057 // expected output for enumerations of this sort: 00058 // 00059 // =========== BASE 26 ENUMERATIONS ========== 00060 // ========= USING THE LATIN ALPHABET ======== 00061 // 00062 // INTEGER NON TYPICAL 00063 // VALUE BIJECTIVE BIJECTIVE 00064 // ======== ========= ========= 00065 // 0 A . 00066 // 1 B A 00067 // 2 C B 00068 // ... ... ... 00069 // 24 Y X 00070 // 25 Z Y 00071 // 26 BA Z 00072 // 27 BB AA 00073 // 28 BC AB 00074 // ... ... ... 00075 // 00076 HexavigesimalConverter(){ _bijective=true; }; 00077 00078 // 00079 // This converts an integer to the Hexavigesimal 00080 // display form: 00081 // 00082 const char *itoa(unsigned int n); 00083 00084 // 00085 // Pass FALSE to get true hexavigesimal output. 00086 // (The default is TRUE which gives bijective 00087 // output): 00088 // 00089 void setBijective(bool b); 00090 00091 }; 00092 00093 #endif