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"