X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Fchart-geometry.c;h=eb0ad9282a854885768472319a899dbfba6c14ea;hb=80595f6de2ea8f0b64756d76c7ac3c89a1abbbb8;hp=573459892e109781e4eaa079ed0d34d5549cbfc7;hpb=8afe280ae36feb9ba7af31094f163795b84f2df8;p=pspp diff --git a/src/math/chart-geometry.c b/src/math/chart-geometry.c index 573459892e..eb0ad9282a 100644 --- a/src/math/chart-geometry.c +++ b/src/math/chart-geometry.c @@ -20,29 +20,30 @@ #include "chart-geometry.h" +static const double standard_ticks[] = {1, 2, 5, 10}; + + /* Adjust tick to be a sensible value ie: ... 0.1,0.2,0.5, 1,2,5, 10,20,50 ... */ double -chart_rounded_tick(double tick) +chart_rounded_tick (double tick) { int i; double diff = DBL_MAX; double t = tick; - static const double standard_ticks[] = {1, 2, 5, 10}; - double factor; /* Avoid arithmetic problems with very small values */ - if (abs (tick) < DBL_EPSILON) + if (fabs (tick) < DBL_EPSILON) return 0; - factor = pow(10,ceil(log10(standard_ticks[0] / tick))) ; + factor = pow (10,ceil (log10 (standard_ticks[0] / tick))); for (i = 3 ; i >= 0 ; --i) { - const double d = fabs( tick - standard_ticks[i] / factor ) ; + const double d = fabs (tick - standard_ticks[i] / factor); if ( d < diff ) { @@ -52,6 +53,5 @@ chart_rounded_tick(double tick) } return t; - }