comparison base/ScaleTickIntervals.h @ 1421:8b7d6c1e1ab7

Adjust rounding; fixes tests on 32-bit Linux test box. Also update one test. Next: recheck everywhere else.
author Chris Cannam
date Thu, 20 Jul 2017 14:52:49 +0100
parents e7e626a87a1e
children 04ce84f21af3
comparison
equal deleted inserted replaced
1420:a533662c17f4 1421:8b7d6c1e1ab7
145 #endif 145 #endif
146 146
147 double min = r.min; 147 double min = r.min;
148 148
149 if (roundTo != 0.0) { 149 if (roundTo != 0.0) {
150 inc = round(inc / roundTo) * roundTo; 150 // Round inc to the nearest multiple of roundTo, and min
151 // to the next multiple of roundTo up. The small offset of
152 // eps is included to avoid inc of 2.49999999999 rounding
153 // to 2 or a min of -0.9999999999 rounding to 0, both of
154 // which would prevent some of our test cases from getting
155 // the most natural results.
156 double eps = 1e-8;
157 inc = round(inc / roundTo + eps) * roundTo;
151 if (inc < roundTo) inc = roundTo; 158 if (inc < roundTo) inc = roundTo;
152 min = ceil(min / roundTo) * roundTo; 159 min = ceil(min / roundTo - eps) * roundTo;
153 if (min > r.max) min = r.max; 160 if (min > r.max) min = r.max;
161 if (min == -0.0) min = 0.0;
162 #ifdef DEBUG_SCALE_TICK_INTERVALS
163 SVDEBUG << "ScaleTickIntervals: rounded inc to " << inc
164 << " and min to " << min << endl;
165 #endif
154 } 166 }
155 167
156 if (display == Scientific && min != 0.0) { 168 if (display == Scientific && min != 0.0) {
157 double digNewMin = log10(fabs(min)); 169 double digNewMin = log10(fabs(min));
158 if (digNewMin < digInc) { 170 if (digNewMin < digInc) {