[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-27 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

Conrad Meyer  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|New |Closed

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-27 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

--- Comment #18 from fernando.apesteg...@gmail.com ---
(In reply to Conrad Meyer from comment #17)
Yes, that's where I got the idea from after playing (unsuccessfully) with the
numbers.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-26 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

--- Comment #17 from Conrad Meyer  ---
Ok, GNU seq basically takes the same approach as your comment #4 patch.  So
I've come around to that.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-26 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

--- Comment #16 from fernando.apesteg...@gmail.com ---
(In reply to Conrad Meyer from comment #15)
I tried to pre-calculate the number of steps and iterate regardless of the
cur<=last condition but it doesn't work either.

I can't see how we can get rid of the rounding error by playing with the
numbers.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-25 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

--- Comment #15 from Conrad Meyer  ---
(In reply to Conrad Meyer from comment #14)
Hm, no, that's still wrong.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-25 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

--- Comment #14 from Conrad Meyer  ---
(In reply to fernando.apesteguia from comment #12)
> cur >= last - (incr / 2);

This one should also be plus.

> The problem with this one is that in some cases, we are not stopping when we 
> should.

Ah, the problem is that 'last' is not a multiple of 'incr'.  Hmm.  Maybe the
terminating math should be: 'trunc(last / incr) * incr + (incr / 2)'.  That is,
round down 'last' to a multiple of 'incr' and then add the epsilon ('incr/2').

That is a little unwieldy for the for loop, of course, but the math can be
moved out.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-25 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

--- Comment #13 from fernando.apesteg...@gmail.com ---
Created attachment 190999
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=190999=edit
seq output for new approach with cur <= last + (incr / 2)

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-25 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

--- Comment #12 from fernando.apesteg...@gmail.com ---
(In reply to Conrad Meyer from comment #11)

OK, this is the new approach:

Index: seq.c
===
--- seq.c   (revisiĆ³n: 329385)
+++ seq.c   (copia de trabajo)
@@ -80,7 +80,10 @@
int equalize = 0;
double first = 1.0;
double last = 0.0;
+   double last_shown_value = 0.0;
+   double cur;
double incr = 0.0;
+   double step;
struct lconv *locale;
char *fmt = NULL;
const char *sep = "\n";
@@ -163,23 +166,19 @@
if (!valid_format(fmt))
errx(1, "invalid format string");
/*
-* XXX to be bug for bug compatible with Plan 9 add a
+* XXX to be bug for bug compatible with Plan 9 add a
 * newline if none found at the end of the format string.
 */
} else
fmt = generate_format(first, incr, last, equalize, pad);

-   if (incr > 0) {
-   for (; first <= last; first += incr) {
-   printf(fmt, first);
-   fputs(sep, stdout);
-   }
-   } else {
-   for (; first >= last; first += incr) {
-   printf(fmt, first);
-   fputs(sep, stdout);
-   }
+   for (step = 1, cur = first; incr > 0 ? cur <= last + (incr / 2) : cur
>= last - (incr / 2);
+   cur = first + incr * step++) {
+   printf(fmt, cur);
+   fputs(sep, stdout);
+   last_shown_value = cur;
}
+
if (term != NULL)
fputs(term, stdout);


The problem with this one is that in some cases, we are not stopping when we
should. For example:

$ seq 1.7 .7 10
1.7
2.4
3.1
3.8
4.5
5.2
5.9
6.6
7.3
8
8.7
9.4 <--- Should have stopped here
10.1 

$ seq 1.07 .07 10
...
...
9.96 <--- Should have stopped here
10.03

I attached a new test file "output_incr_over_two.txt"

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-25 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

--- Comment #11 from Conrad Meyer  ---
(In reply to fernando.apesteguia from comment #10)
> Do you mean something like this?

Oh, sorry, I meant (incr/2) not (step/2).  And also for the negative incr case,
of course.  But otherwise, yes.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-25 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

--- Comment #10 from fernando.apesteg...@gmail.com ---
(In reply to Conrad Meyer from comment #9)

Do you mean something like this?

Index: seq.c
===
--- seq.c   (revisiĆ³n: 329385)
+++ seq.c   (copia de trabajo)
@@ -80,7 +80,10 @@
int equalize = 0;
double first = 1.0;
double last = 0.0;
+   double last_shown_value = 0.0;
+   double cur;
double incr = 0.0;
+   double step;
struct lconv *locale;
char *fmt = NULL;
const char *sep = "\n";
@@ -163,23 +166,19 @@
if (!valid_format(fmt))
errx(1, "invalid format string");
/*
-* XXX to be bug for bug compatible with Plan 9 add a
+* XXX to be bug for bug compatible with Plan 9 add a
 * newline if none found at the end of the format string.
 */
} else
fmt = generate_format(first, incr, last, equalize, pad);

-   if (incr > 0) {
-   for (; first <= last; first += incr) {
-   printf(fmt, first);
-   fputs(sep, stdout);
-   }
-   } else {
-   for (; first >= last; first += incr) {
-   printf(fmt, first);
-   fputs(sep, stdout);
-   }
+   for (step = 1, cur = first; incr > 0 ? cur <= last + (step/2) : cur >=
last;
+   cur = first + incr * step++) {
+   printf(fmt, cur);
+   fputs(sep, stdout);
+   last_shown_value = cur;
}
+
if (term != NULL)
fputs(term, stdout);

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-25 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

Conrad Meyer  changed:

   What|Removed |Added

 CC||c...@freebsd.org

--- Comment #9 from Conrad Meyer  ---
Instead of the final string comparison, could we change the loop limit to 'cur
<= last + (step/2)'?

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

--- Comment #6 from fernando.apesteg...@gmail.com ---
Created attachment 190657
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=190657=edit
seq output from FreeBSD current

seq output generated in FreeBSD current with patches applied.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

--- Comment #7 from fernando.apesteg...@gmail.com ---
Created attachment 190658
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=190658=edit
seq output generator

generator of different seq executions.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

--- Comment #5 from fernando.apesteg...@gmail.com ---
Created attachment 190656
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=190656=edit
seq output from ubuntu

Output generated in an Ubuntu system

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-12 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

Mark Linimon  changed:

   What|Removed |Added

   Keywords||patch

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-02-12 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

fernando.apesteg...@gmail.com changed:

   What|Removed |Added

 CC||fernando.apesteguia@gmail.c
   ||om

--- Comment #4 from fernando.apesteg...@gmail.com ---
Created attachment 190550
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=190550=edit
patch to /usr.bin/seq/seq.c

I added some lines on top of Yuri's patch to handle the special case of missing
'last'. With this new patch:

$ ./seq 1.6 .05 2
1.6
1.65
1.7
1.75
1.8
1.85
1.9
1.95
2

$ ./seq 1.65 .05 2
1.65
1.7
1.75
1.8
1.85
1.9
1.95
2

$ ./seq 1.1 0.1 1.2
1.1
1.2

$ ./seq 1.1 0.3 1.2
1.1

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-01-19 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

Jilles Tjoelker  changed:

   What|Removed |Added

 CC||jil...@freebsd.org

--- Comment #3 from Jilles Tjoelker  ---
This patch looks like an improvement but will not fix everything. In some
cases, a single addition causes an unexpected result: "seq 1.1 0.1 1.2" prints
just 1.1, and the patch will not fix that. GNU seq prints both 1.1 and 1.2.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-01-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

Yuri Pankov  changed:

   What|Removed |Added

 Attachment #189755|0   |1
is obsolete||

--- Comment #2 from Yuri Pankov  ---
Created attachment 189760
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=189760=edit
Don't accumulate rounding errors

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2018-01-15 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

Yuri Pankov  changed:

   What|Removed |Added

 CC||yur...@icloud.com

--- Comment #1 from Yuri Pankov  ---
Created attachment 189755
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=189755=edit
Don't accumulate rounding errors

As I was educated on current@, many exact fractions in base-10 aren't exact in
base-2, so using the for() loop accumulates rounding errors.  Work around that
re-computing current value for every step.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"


[Bug 217149] seq(1) inconsistently omits 'last' when using float increment

2017-02-16 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217149

Bug ID: 217149
   Summary: seq(1) inconsistently omits 'last' when using float
increment
   Product: Base System
   Version: 11.0-STABLE
  Hardware: Any
OS: Any
Status: New
  Severity: Affects Some People
  Priority: ---
 Component: bin
  Assignee: freebsd-bugs@FreeBSD.org
  Reporter: mcdutc...@hotmail.com

With a 'first' parameter up to 1.6, seq(1) will not print the '2':

$ seq 1.6 .05 2
1.6
1.65
1.7
1.75
1.8
1.85
1.9
1.95

but, starting from 1.65, it will:

$ seq 1.65 .05 2
1.65
1.7
1.75
1.8
1.85
1.9
1.95
2

GNU 'seq' always prints the 2.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"