Skip to content

Commit 7953c5b

Browse files
committed
range
1 parent c26696f commit 7953c5b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/org/devore/module/CoreModule.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,8 @@ else if (ast.size() > 2)
747747
throw new DevoreCastException(args.get(1).type(), "number");
748748
if (args.size() > 2 && !(args.get(2) instanceof DNumber))
749749
throw new DevoreCastException(args.get(2).type(), "number");
750-
boolean isFloat = args.getFirst() instanceof DFloat || args.get(1) instanceof DFloat || args.get(2) instanceof DFloat;
750+
boolean isFloat = args.getFirst() instanceof DFloat ||
751+
(args.size() > 1 && args.get(1) instanceof DFloat) || (args.size() > 2 && args.get(2) instanceof DFloat);
751752
BigDecimal start, end, step;
752753
if (args.size() > 1) {
753754
start = ((DNumber) args.get(0)).toBigDecimal();
@@ -765,13 +766,13 @@ else if (ast.size() > 2)
765766
for (BigDecimal current = start;
766767
current.compareTo(end) <= 0;
767768
current = current.add(step)) {
768-
list.add(isFloat ? DInt.valueOf(current) : DFloat.valueOf(current));
769+
list.add(!isFloat ? DInt.valueOf(current) : DFloat.valueOf(current));
769770
}
770771
} else {
771772
for (BigDecimal current = start;
772773
current.compareTo(end) >= 0;
773774
current = current.add(step)) {
774-
list.add(isFloat ? DInt.valueOf(current) : DFloat.valueOf(current));
775+
list.add(!isFloat ? DInt.valueOf(current) : DFloat.valueOf(current));
775776
}
776777
}
777778
return DList.valueOf(list);

0 commit comments

Comments
 (0)