+char *opt_set_floatval(const char *arg, float *f)
+{
+ double d;
+ char *err;
+
+ err = opt_set_doubleval(arg, &d);
+ if (err)
+ return err;
+
+ *f = d;
+ if (*f != d)
+ return arg_bad("'%s' is out of range", arg);
+
+ return NULL;
+}
+
+void opt_show_floatval(char buf[OPT_SHOW_LEN], const float *f)
+{
+ double d = *f;
+ opt_show_doubleval(buf, &d);
+}
+
+char *opt_set_doubleval(const char *arg, double *d)
+{
+ char *endp;
+
+ /* This is how the manpage says to do it. Yech. */
+ errno = 0;
+ /* Don't assume strtof */
+ *d = strtod(arg, &endp);
+ if (*endp || !arg[0])
+ return arg_bad("'%s' is not a number", arg);
+ if (errno)
+ return arg_bad("'%s' is out of range", arg);
+
+ return NULL;
+}
+
+void opt_show_doubleval(char buf[OPT_SHOW_LEN], const double *d)
+{
+ snprintf(buf, OPT_SHOW_LEN, "%f", *d);
+}
+