Skip to content

Commit

Permalink
[SYSTEMDS-3833] Fix seq() length primitive (pos/neg increment)
Browse files Browse the repository at this point in the history
  • Loading branch information
mboehm7 committed Feb 9, 2025
1 parent 775d06a commit 6653ced
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,10 @@ public static long getSeqLength(double from, double to, double incr, boolean che
return 0; // invalid loop configuration
}
long tmp = (long) Math.floor(to/incr - from/incr);
return 1L + tmp + ((from+tmp*incr < to) ? 1 : 0);
if( incr > 0 )
return 1L + tmp + ((from+(tmp+1)*incr <= to) ? 1 : 0);
else
return 1L + tmp + ((from+(tmp+1)*incr >= to) ? 1 : 0);
}

/**
Expand Down

0 comments on commit 6653ced

Please sign in to comment.