00001 #include "EdgeCalculator.h" 00002 #include <cmath> 00003 00004 bool 00005 Anaphe::AIDA_Histogram_native::EdgeCalculator::calculateEdges( double edgeLow, 00006 double edgeHigh, 00007 int bins, 00008 double& newEdgeLow, 00009 double& newEdgeHigh ) const 00010 { 00011 if ( bins == 0 ) return false; 00012 if ( edgeHigh <= edgeLow ) return false; 00013 const double binSize = ( edgeHigh - edgeLow ) / bins; 00014 const double magnitude = std::floor( std::log10( binSize ) ); 00015 const double precision = std::pow( 10, magnitude ); 00016 00017 newEdgeHigh = precision * ( std::floor( edgeHigh / precision ) + 1 ); 00018 newEdgeLow = precision * std::floor( edgeLow / precision ); 00019 00020 return true; 00021 }