IEEEFloat32.h

Go to the documentation of this file.
00001 
00015 #ifndef _DLR_IEEEFLOAT32_H_
00016 #define _DLR_IEEEFLOAT32_H_
00017 
00018 #include <dlrCommon/exception.h>
00019 
00020 namespace dlr {
00021 
00022   namespace numeric {
00023 
00053     class IEEEFloat32 {
00054     public:
00055 
00062       typedef float FloatType;
00063 
00064     
00068       IEEEFloat32();
00069 
00070 
00078       IEEEFloat32(FloatType value);
00079 
00080 
00099       IEEEFloat32(unsigned char byte0,
00100                   unsigned char byte1,
00101                   unsigned char byte2,
00102                   unsigned char byte3);
00103 
00104 
00111       IEEEFloat32(const IEEEFloat32& source);
00112 
00113 
00118       ~IEEEFloat32() {}
00119 
00120 
00127       operator
00128       FloatType() const {return static_cast<FloatType>(m_value);}
00129     
00130 
00145       unsigned char
00146       getByte(size_t index0);
00147 
00148 
00158       FloatType
00159       getFloat() {return static_cast<FloatType>(*this);}
00160 
00161     
00169       void
00170       setValue(FloatType value);
00171 
00172 
00191       void
00192       setValue(unsigned char byte0,
00193                unsigned char byte1,
00194                unsigned char byte2,
00195                unsigned char byte3);
00196 
00197     
00198     private:
00227       void
00228       binaryToFloat(unsigned char byte0,
00229                     unsigned char byte1,
00230                     unsigned char byte2,
00231                     unsigned char byte3,
00232                     FloatType& value);
00233 
00234     
00240       void
00241       checkTypes();
00242           
00243 
00270       void
00271       floatToBinary(FloatType value,
00272                     unsigned char& byte0,
00273                     unsigned char& byte1,
00274                     unsigned char& byte2,
00275                     unsigned char& byte3);
00276 
00277     
00282       FloatType m_value;
00283 
00288       unsigned char m_bytes[4];
00289     }; // class IEEEFloat32
00290 
00291   } // namespace numeric
00292 
00293 } // namespace dlr
00294 
00295 
00296 /* ======= Declarations to maintain compatibility with legacy code. ======= */
00297 
00298 namespace dlr {
00299 
00300   using numeric::IEEEFloat32;
00301 
00302 } // namespace dlr
00303 
00304 #endif // #ifndef _DLR_IEEEFLOAT32_H_

Generated on Wed Nov 25 00:42:42 2009 for dlrUtilities Utility Library by  doxygen 1.5.8