Added unit tests and fixed rounding problem in ArrayUtils.range().
[debian/openrocket] / core / src / net / sf / openrocket / util / ArrayUtils.java
index 59290b12d9c8fd48401436ad62bf93dffc2330f4..8e504a55e7ea37abe45c114eef7002367b51b28b 100644 (file)
@@ -10,7 +10,12 @@ public class ArrayUtils {
         */
        public static double[] range(double start, double stop, double step){
                
-               int size = (int) Math.floor(((stop - start) / step));
+               int size = 0 ;
+               if ( stop <= start ) {
+                       size = 0;
+               } else {
+                       size = (int) Math.ceil(((stop - start) / step));
+               }
                
                //System.out.println("Range from "+start+" to "+stop+" step "+step+" has length "+size);