projects
/
debian
/
openrocket
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added unit tests and fixed rounding problem in ArrayUtils.range().
[debian/openrocket]
/
core
/
src
/
net
/
sf
/
openrocket
/
util
/
ArrayUtils.java
diff --git
a/core/src/net/sf/openrocket/util/ArrayUtils.java
b/core/src/net/sf/openrocket/util/ArrayUtils.java
index 59290b12d9c8fd48401436ad62bf93dffc2330f4..8e504a55e7ea37abe45c114eef7002367b51b28b 100644
(file)
--- a/
core/src/net/sf/openrocket/util/ArrayUtils.java
+++ b/
core/src/net/sf/openrocket/util/ArrayUtils.java
@@
-10,7
+10,12
@@
public class ArrayUtils {
*/
public static double[] range(double start, double stop, double step){
*/
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);
//System.out.println("Range from "+start+" to "+stop+" step "+step+" has length "+size);