magic-elimination.patch from patch #6230.
[pspp-builds.git] / src / libpspp / float-format.c
index 7d65375ada731657a8ea50c221d843f8dacdb21e..50a4eae6005b071e1d61320621aa424614fd2654 100644 (file)
@@ -106,6 +106,16 @@ float_convert (enum float_format from, const void *src,
     }
 }
 
+/* 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
@@ -177,6 +187,24 @@ float_identify (double expected_value, const void *number, size_t length,
       }
   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