Mercurial > hg > octave-lyh
diff src/graphics.cc @ 12508:919cadf334f8
Simplify calculation of number of tick labels. Bug #32692.
author | Marco Caliari <marco.caliari@univr.it> |
---|---|
date | Tue, 15 Mar 2011 22:45:31 -0700 |
parents | 0dda50ae4997 |
children | 570193964185 |
line wrap: on
line diff
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -4976,8 +4976,8 @@ } } -// magform(x) Returns (a, b), where x = a * 10^b, a >= 1., and b is -// integral. +// magform(x) Returns (a, b), where x = a * 10^b, abs (a) >= 1., and b is +// integer. static void magform (double x, double& a, int& b) @@ -4989,18 +4989,8 @@ } else { - double l = std::log10 (std::abs (x)); - double r = std::fmod (l, 1.); - a = std::pow (10.0, r); - b = static_cast<int> (l-r); - if (a < 1) - { - a *= 10; - b -= 1; - } - - if (x < 0) - a = -a; + b = static_cast<int> (gnulib::floor (std::log10 (std::abs (x)))); + a = x / std::pow (10.0, b); } }