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 = (int) (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;
43 if (roundedMin + nominalStep <= xMax) {
52 m_firstSimplestNumber = roundedMin;
57 return m_firstSimplestNumber;
60 double ExportAlignLinear::log10 (
double in)
const
62 return qLn (in) / qLn (10.0);
65 double ExportAlignLinear::roundToDigit (
double value,
68 double scale = qPow (10.0, digit);
69 int valueRoundedWithWrongScale = (int) (value / scale + EPSILON);
70 double valueRounded = valueRoundedWithWrongScale * scale;
ExportAlignLinear(double xMin, double xMax)
Single constructor.
double firstSimplestNumber() const
Result.