00001 // 00002 // $Id: FloatingPoint.h,v 1.1 2008/07/14 17:50:46 lxmota Exp $ 00003 // 00004 // $Log: FloatingPoint.h,v $ 00005 // Revision 1.1 2008/07/14 17:50:46 lxmota 00006 // Initial sources. 00007 // 00008 // 00009 00010 // 00011 // 2001/10/02 22:45:15 by Jaroslaw Knap 00012 // Imported sources. 00013 // 00014 00015 #if !defined(LCM_FloatingPoint_h) 00016 #define LCM_FloatingPoint_h 00017 00018 namespace LCM { 00019 00020 const unsigned emptyMask_ = 0x00; 00021 const unsigned inexactMask_ = 0x01; 00022 const unsigned divbyzeroMask_ = 0x02; 00023 const unsigned underflowMask_ = 0x04; 00024 const unsigned overflowMask_ = 0x08; 00025 const unsigned invalidMask_ = 0x10; 00026 00027 class FloatingPoint { 00028 00029 public: 00030 00031 FloatingPoint(); 00032 virtual ~FloatingPoint(); 00033 00034 void trapInexact(); 00035 void trapDivbyzero(); 00036 void trapUnderflow(); 00037 void trapOverflow(); 00038 void trapInvalid(); 00039 00040 00041 private: 00042 00043 static bool active_; 00044 static unsigned mask_; 00045 static unsigned oldMask_; 00046 00047 // obtain and store current masks status; 00048 unsigned getCurrentMask(); 00049 00050 // set mask 00051 void setMask(unsigned mask); 00052 00053 }; 00054 00055 } // namespace LCM 00056 00057 #endif // LCM_FloatingPoint_h