+ }
}
diff -upr src/seq.c src/seq.c
---- src/seq.c 2007-07-23 12:56:20.000000000 +0200
-+++ src/seq.c 2007-07-23 13:03:12.000000000 +0200
-@@ -164,6 +164,7 @@ scan_arg (const char *arg)
+--- src/seq.c 2008-04-14 11:17:15.000000000 +0200
++++ src/seq.c 2008-04-14 11:26:57.000000000 +0200
+@@ -166,6 +166,7 @@ scan_arg (const char *arg)
: (decimal_point == arg /* .# -> 0.# */
|| ! ISDIGIT (decimal_point[-1]))); /* -.# -> 0.# */
}
char const *e = strchr (arg, 'e');
if (! e)
e = strchr (arg, 'E');
-@@ -172,6 +173,7 @@ scan_arg (const char *arg)
+@@ -174,6 +175,7 @@ scan_arg (const char *arg)
long exponent = strtol (e + 1, NULL, 10);
ret.precision += exponent < 0 ? -exponent : 0;
}
}
return ret;
-@@ -339,6 +341,7 @@ get_default_format (operand first, opera
+@@ -349,6 +351,7 @@ get_default_format (operand first, opera
size_t last_width = last.width + (prec - last.precision);
if (last.precision && prec == 0)
last_width--; /* don't include space for '.' */
size_t width = MAX (first_width, last_width);
if (width <= INT_MAX)
{
-@@ -346,6 +349,7 @@ get_default_format (operand first, opera
+@@ -356,6 +359,7 @@ get_default_format (operand first, opera
sprintf (format_buf, "%%0%d.%dLf", w, prec);
return format_buf;
}
}
else
{
-@@ -434,6 +438,7 @@ main (int argc, char **argv)
+@@ -444,6 +448,7 @@ main (int argc, char **argv)
if (format_str)
{
validate_format (format_str);
char const *f = long_double_format (format_str, &layout);
if (! f)
{
-@@ -441,6 +446,7 @@ main (int argc, char **argv)
+@@ -451,6 +456,7 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
format_str = f;
#include <getopt.h>
#include <stdio.h>
#include <sys/types.h>
+#include <math.h>
+#include <float.h>
#include "system.h"
#include "c-strtod.h"
return NULL;
}
+/* Return the absolute relative difference from x to y. */
+static double
+abs_rel_diff (double x, double y)
+{
+ double s = (y == 0.0 ? 1 : y);
+ return fabs ((y - x) / s);
+}
+
/* Actually print the sequence of numbers in the specified range, with the
given or default stepping and format. */
x_str[x_strlen - layout.suffix_len] = '\0';
if (xstrtold (x_str + layout.prefix_len, NULL, &x_val, c_strtold)
- && x_val == last)
+ && abs_rel_diff (x_val, last) < DBL_EPSILON)
{
char *x0_str = NULL;
if (asprintf (&x0_str, fmt, x0) < 0)