-/* PSPP - computes sample statistics.
- Copyright (C) 2006 Free Software Foundation, Inc.
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 2006, 2011 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
+ GNU General Public License for more details.
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 <libpspp/float-format.h>
+#include "libpspp/float-format.h"
+#include <byteswap.h>
#include <ctype.h>
#include <inttypes.h>
#include <stdlib.h>
+#include <string.h>
-#include <libpspp/assertion.h>
-#include <libpspp/integer-format.h>
-#include <libpspp/str.h>
+#include "libpspp/assertion.h"
+#include "libpspp/integer-format.h"
-#include "error.h"
-#include <byteswap.h>
\f
/* Neutral intermediate representation for binary floating-point numbers. */
struct fp
}
}
+/* Converts SRC from format FROM to a native double and returns
+ the double. */
+double
+float_get_double (enum float_format from, const void *src)
+{
+ double dst;
+ float_convert (from, src, FLOAT_NATIVE_DOUBLE, &dst);
+ return dst;
+}
+
/* Returns the number of bytes in a number in the given
FORMAT. */
size_t
}
return match_cnt;
}
+
+/* Returns the double value that is just greater than -DBL_MAX,
+ which in PSPP syntax files is called LOWEST and used as the
+ low end of numeric ranges that are supposed to be unbounded on
+ the low end, as in the missing value set created by,
+ e.g. MISSING VALUES X(LOWEST THRU 5). (-DBL_MAX is used for
+ SYSMIS so it is not available for LOWEST.) */
+double
+float_get_lowest (void)
+{
+ struct fp fp;
+ double x;
+
+ fp.class = LOWEST;
+ fp.sign = POSITIVE;
+ assemble_number (FLOAT_NATIVE_DOUBLE, &fp, &x);
+ return x;
+}
\f
/* Returns CNT bits in X starting from the given bit OFS. */
static inline uint64_t
break;
case FLOAT_Z_SHORT:
- put_uint64 (native_to_be32 (assemble_z (fp, 7, 24)), number);
+ put_uint32 (native_to_be32 (assemble_z (fp, 7, 24)), number);
break;
case FLOAT_Z_LONG:
put_uint64 (native_to_be64 (assemble_z (fp, 7, 56)), number);