7 #include "EngaugeAssert.h" 8 #include "ExportAlignLinear.h" 11 const double EPSILON = 0.000001;
15 m_firstSimplestNumber (0)
17 ENGAUGE_ASSERT (xMin <= xMax);
23 double absMin = qAbs (xMin);
24 double absMax = qAbs (xMax);
25 int D = qFloor (log10 (qMax (absMin, absMax)) + EPSILON);
31 double roundedMin = 0.0;
34 roundedMin = roundToDigit (xMin, R);
35 double nominalStep = qPow (10.0, R);
37 if (xMin < 0 && xMin < roundedMin) {
40 roundedMin -= nominalStep;
44 if (roundedMin + 2 * nominalStep <= xMax) {
51 m_firstSimplestNumber = roundedMin;
56 return m_firstSimplestNumber;
59 double ExportAlignLinear::log10 (
double in)
const 61 return qLn (in) / qLn (10.0);
64 double ExportAlignLinear::roundToDigit (
double value,
67 double scale = qPow (10.0, digit);
68 int valueRoundedWithWrongScale = qFloor (value / scale + EPSILON);
69 double valueRounded = valueRoundedWithWrongScale * scale;
ExportAlignLinear(double xMin, double xMax)
Single constructor.
double firstSimplestNumber() const
Result.