pxd: initial work
[pspp] / src / data / format.c
index 3a380bda45c0d960758739531289436da37f7af9..52206b0f539af86040e4de071d92431f526321dd 100644 (file)
@@ -558,6 +558,22 @@ fmt_change_decimals (struct fmt_spec *fmt, int decimals, enum fmt_use use)
   fmt->d = decimals;
   fmt_fix (fmt, use);
 }
+
+unsigned int
+fmt_to_uint (const struct fmt_spec *fmt)
+{
+  return (fmt_to_io (fmt->type) << 24) | (fmt->w << 8) | fmt->d;
+}
+
+bool
+fmt_from_uint (struct fmt_spec *fmt, unsigned int uint)
+{
+  if (!fmt_from_io (uint >> 24, &fmt->type))
+    return false;
+  fmt->w = (uint >> 8) & 0xffff;
+  fmt->d = uint & 0xff;
+  return true;
+}
 \f
 /* Describes a display format. */
 struct fmt_desc
@@ -1158,3 +1174,6 @@ get_fmt_desc (enum fmt_type type)
 }
 
 const struct fmt_spec F_8_0 = {FMT_F, 8, 0};
+const struct fmt_spec F_8_2 = {FMT_F, 8, 2};
+const struct fmt_spec F_4_3 = {FMT_F, 4, 3};
+const struct fmt_spec F_5_1 = {FMT_F, 5, 1};