FreeBSD Bugzilla – Attachment 189760 Details for
Bug 217149
seq(1) inconsistently omits 'last' when using float increment
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Don't accumulate rounding errors
0001-Don-t-accumulate-rounding-errors.patch (text/plain), 1.44 KB, created by
Yuri Pankov
on 2018-01-15 19:32:38 UTC
(
hide
)
Description:
Don't accumulate rounding errors
Filename:
MIME Type:
Creator:
Yuri Pankov
Created:
2018-01-15 19:32:38 UTC
Size:
1.44 KB
patch
obsolete
>From 3e24be515d9943d8bf31bb53dd50fd1d525b5b2c Mon Sep 17 00:00:00 2001 >From: Yuri Pankov <yuripv@icloud.com> >Date: Mon, 15 Jan 2018 20:23:31 +0300 >Subject: [PATCH] Don't accumulate rounding errors > >--- > usr.bin/seq/seq.c | 18 +++++++----------- > 1 file changed, 7 insertions(+), 11 deletions(-) > >diff --git a/usr.bin/seq/seq.c b/usr.bin/seq/seq.c >index b8c3faef7bf1..8dad53258fd7 100644 >--- a/usr.bin/seq/seq.c >+++ b/usr.bin/seq/seq.c >@@ -80,7 +80,9 @@ main(int argc, char *argv[]) > int equalize = 0; > double first = 1.0; > double last = 0.0; >+ double cur; > double incr = 0.0; >+ double step; > struct lconv *locale; > char *fmt = NULL; > const char *sep = "\n"; >@@ -163,22 +165,16 @@ main(int argc, char *argv[]) > 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 : cur >= last; >+ cur = first + incr * step++) { >+ printf(fmt, cur); >+ fputs(sep, stdout); > } > if (term != NULL) > fputs(term, stdout); >-- >2.15.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 217149
:
189755
| 189760 |
190550
|
190656
|
190657
|
190658
|
190999