00001 //////////////////////////////////////////////////////////////////////// 00002 // How to use this file: // 00003 // ===================== // 00004 // #define NUMBER Double /* The name of the class */ // 00005 // #define TYPE double /* The storage data type */ // 00006 // #define ZERO 0.0 /* The value zero in that data type */ // 00007 // // 00008 // class Double { // 00009 // // ... // 00010 // #include <j2k/Fred/Math/Number/NbVerify.hpp> // 00011 // #include <j2k/Fred/Math/Number/NbOperator1.hpp> // 00012 // // 00013 // /* Operator right handside */ // 00014 // /* Might consider automatic type upgrading for simplicity... // 00015 // #define TYPE2 double // 00016 // #include <j2k/Fred/Math/Number/NbOperator2.hpp> // 00017 // // 00018 // #define TYPE2 float // 00019 // #include <j2k/Fred/Math/Number/NbOperator2.hpp> // 00020 // // 00021 // #define TYPE2 signed long // 00022 // #include <j2k/Fred/Math/Number/NbOperator2.hpp> // 00023 // #define TYPE2 unsigned long // 00024 // #include <j2k/Fred/Math/Number/NbOperator2.hpp> // 00025 // // 00026 // #define TYPE2 signed short // 00027 // #include <j2k/Fred/Math/Number/NbOperator2.hpp> // 00028 // #define TYPE2 unsigned short // 00029 // #include <j2k/Fred/Math/Number/NbOperator2.hpp> // 00030 // // 00031 // #define TYPE2 signed char // 00032 // #include <j2k/Fred/Math/Number/NbOperator2.hpp> // 00033 // #define TYPE2 unsigned char // 00034 // #include <j2k/Fred/Math/Number/NbOperator2.hpp> // 00035 // // 00036 // #define TYPE2 signed int // 00037 // #include <j2k/Fred/Math/Number/NbOperator2.hpp> // 00038 // #define TYPE2 unsigned int // 00039 // #include <j2k/Fred/Math/Number/NbOperator2.hpp> // 00040 // }; // 00041 // #undef TYPE // 00042 // #undef ZERO // 00043 // #undef NUMBER // 00044 //////////////////////////////////////////////////////////////////////// 00045 00046 // Missing += *= -= /= <<= >>= &&= &= |= etc. 00047 // Too long to do it by hand, so let's do it with an #include Macro ! =) 00048 00049 #ifndef TYPE 00050 #error "TYPE is not defined !" 00051 #endif 00052 00053 #ifndef NUMBER 00054 #error "NUMBER is not defined !" 00055 #endif 00056 00057 inline NUMBER operator<< (const NUMBER& l, const NUMBER& r) { 00058 return NUMBER( l.value << r.value); 00059 } 00060 00061 inline NUMBER operator>> (const NUMBER& l, const NUMBER& r) { 00062 return NUMBER(l.value >> r.value); 00063 } 00064 00065 inline NUMBER operator | (const NUMBER& l, const NUMBER& r) { 00066 return NUMBER(l.value | r.value); 00067 } 00068 00069 inline NUMBER operator & (const NUMBER& l, const NUMBER& r) { 00070 return NUMBER(l.value & r.value); 00071 } 00072 00073 inline NUMBER operator ^ (const NUMBER& l, const NUMBER& r) { 00074 return NUMBER(l.value ^ r.value); 00075 }