projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
FREQUENCIES: Fix treatment of string variables.
[pspp]
/
src
/
math
/
chart-geometry.c
diff --git
a/src/math/chart-geometry.c
b/src/math/chart-geometry.c
index 6ae5ebabc2cf67a1d9a728472d37df994c9565bd..eb0ad9282a854885768472319a899dbfba6c14ea 100644
(file)
--- a/
src/math/chart-geometry.c
+++ b/
src/math/chart-geometry.c
@@
-1,20
+1,18
@@
-/* PSPP -
computes sample statistic
s.
+/* PSPP -
a program for statistical analysi
s.
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004 Free Software Foundation, Inc.
- This program is free software
; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
-
License, or
(at your option) any later version.
+ This program is free software
: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful,
but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU
- General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+
but
WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ G
NU G
eneral Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <math.h>
#include <config.h>
#include <math.h>
@@
-22,24
+20,30
@@
#include "chart-geometry.h"
#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
/* 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;
int i;
double diff = DBL_MAX;
double t = tick;
-
static const double standard_ticks[] = {1, 2, 5, 10}
;
+
double factor
;
- const double factor = pow(10,ceil(log10(standard_ticks[0] / tick))) ;
+ /* Avoid arithmetic problems with very small values */
+ if (fabs (tick) < DBL_EPSILON)
+ return 0;
+
+ factor = pow (10,ceil (log10 (standard_ticks[0] / tick)));
for (i = 3 ; i >= 0 ; --i)
{
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 )
{
if ( d < diff )
{
@@
-49,6
+53,5
@@
chart_rounded_tick(double tick)
}
return t;
}
return t;
-
}
}