diff -r 1c999569643b -r acf2c31e22d4 samples/composition/src-api2.0-property/api/Arithmetica.java --- a/samples/composition/src-api2.0-property/api/Arithmetica.java Sat Jun 14 10:04:51 2008 +0200 +++ b/samples/composition/src-api2.0-property/api/Arithmetica.java Sat Jun 14 10:04:53 2008 +0200 @@ -36,6 +36,10 @@ private int sumRange1(int from, int to) { int len = to - from; + if (len < 0) { + len = -len; + from = to; + } int[] array = new int[len + 1]; for (int i = 0; i <= len; i++) { array[i] = from + i; @@ -44,7 +48,7 @@ } private int sumRange2(int from, int to) { - return (from + to) * (to - from + 1) / 2; + return (from + to) * (Math.abs(to - from) + 1) / 2; } } // END: design.composition.arith2.0.property