Mercurial > hg > octave-lojdl
changeset 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 | 41d183070c04 |
children | e742720c5e71 |
files | src/ChangeLog src/graphics.cc |
diffstat | 2 files changed, 9 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-03-15 Marco Caliari <marco.caliari@univr.it> + + * graphics.cc: Simplify calculation of number of tick labels. Fixes + bug #32692. + 2011-03-13 Konstantinos Poulios <logari81@googlemail.com> * DLD-FUNCTIONS/__init_fltk__.cc (plot_window::plot_window):
--- 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); } }