+static VALUE
+int_to_eet_chunks (int argc, VALUE *argv, VALUE self)
+{
+ VALUE tag, type = Qnil, ary, args[2], chunk;
+ char *cfmt = "V";
+
+ rb_scan_args (argc, argv, "11", &tag, &type);
+
+ ary = rb_ary_new3 (1, self);
+
+ if (type == sym_char)
+ cfmt = "c";
+ else if (type == sym_short)
+ cfmt = "v";
+ else if (type == sym_long_long)
+ cfmt = "q";
+
+ args[0] = tag;
+ args[1] = rb_funcall (ary, id_pack, 1, rb_str_new2 (cfmt));
+ chunk = rb_class_new_instance (2, args, cChunk);
+
+ return rb_ary_new3 (1, chunk);
+}
+
+static VALUE
+float_to_eet_chunks (int argc, VALUE *argv, VALUE self)
+{
+ VALUE tag, type = Qnil, args[2], chunk;
+ char buf[65], *loc;
+ double d;
+ int len;
+
+ rb_scan_args (argc, argv, "11", &tag, &type);
+
+ d = NUM2DBL (self);
+
+ /* switch locale to make sure we get proper snprintf output */
+ loc = setlocale (LC_NUMERIC, "C");
+
+ len = snprintf (buf, sizeof (buf) - 1, "%a",
+ type == sym_double ? d : (float) d);
+
+ if (loc)
+ setlocale (LC_NUMERIC, loc);
+
+ buf[++len] = '\0';
+
+ args[0] = tag;
+ args[1] = rb_str_new (buf, len);
+ chunk = rb_class_new_instance (2, args, cChunk);
+
+ return rb_ary_new3 (1, chunk);