MCPcopy Index your code
hub / github.com/clojure/clojure / rangeCount

Method rangeCount

src/jvm/clojure/lang/LongRange.java:49–54  ·  view source on GitHub ↗
(long start, long end, long step)

Source from the content-addressed store, hash-verified

47
48// returns exact size of remaining items OR throws ArithmeticException for overflow case
49static long rangeCount(long start, long end, long step) {
50 // (1) count = ceiling ( (end - start) / step )
51 // (2) ceiling(a/b) = (a+b+o)/b where o=-1 for positive stepping and +1 for negative stepping
52 // thus: count = end - start + step + o / step
53 return Numbers.add(Numbers.add(Numbers.minus(end, start), step), step > 0 ? -1 : 1) / step;
54}
55
56public static ISeq create(long end) {
57 if(end > 0) {

Callers 1

createMethod · 0.95

Calls 2

addMethod · 0.95
minusMethod · 0.95

Tested by

no test coverage detected