From: Paul Eggert Date: Mon, 29 Jan 2024 07:35:49 +0000 (-0800) Subject: seq: say why not ‘x += step’ X-Git-Tag: v9.5~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ec1fb46aba4b72623e4aab1a682466f68f5fdf3;p=thirdparty%2Fcoreutils.git seq: say why not ‘x += step’ * src/seq.c (print_numbers): Add comment. --- diff --git a/src/seq.c b/src/seq.c index 3d2c1c2ea2..ad16f27018 100644 --- a/src/seq.c +++ b/src/seq.c @@ -307,7 +307,11 @@ print_numbers (char const *fmt, struct layout layout, write_error (); if (out_of_range) break; + + /* Mathematically equivalent to 'x += step;', and typically + less subject to rounding error. */ x = first + i * step; + out_of_range = (step < 0 ? x < last : last < x); if (out_of_range)