Misc.h

Go to the documentation of this file.
00001 // Copyright CERN 2012 - Developed in collaboration with GSI
00002 
00003 #ifndef MISC_H_
00004 #define MISC_H_
00005 
00006 #include <cmath>
00007 #include <limits>
00008 
00009 namespace fesa
00010 {
00011 
00016 class Miscellaneous
00017 {
00018   public:
00023     static uint32_t digits(int64_t number)
00024     {
00025         // Avoid doing work if number is 0
00026         if (number != 0)
00027         {
00028             double lg = log10((double) abs(number));
00029             double eps = std::numeric_limits<double>::epsilon();
00030             return static_cast<uint32_t> (1 + lg + eps);
00031         }
00032         else
00033             return 1;
00034     }
00035 };
00036 
00037 } // fesa
00038 
00039 #endif // MISC_H_

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1