santhosh-tekuri/jlibs

Inconsistent Random interface

GoogleCodeExporter opened this issue · 1 comments

The functions defined in 
\jlibs-read-only\core\src\main\java\jlibs\core\util\RandomUtil.java
have an inconsistent interface.

max is excluded in
double random(double min, double max)     [and float]
but included in
int random(int min, int max)              [and short, long, byte]


This complicates the usage of these standard functions.

Possible solutions:
1. either include or exclude max in all cases.
2. add javadoc documentation, such that the user can read what the function 
does without the need to look at the actual implementation file.
 The additional documentation could look like:
    /** Random integer value
      * @param min minimum integer value (inclusive)
      * @param max maximum integer value (inclusive)
      * @return a random integer in the range [min, max]
      */
    public static int random(int min, int max)

Original issue reported on code.google.com by Pierre.v...@gmail.com on 3 Dec 2013 at 1:35

Hi,

Beacuse of this defect default value setting for xml generating from xsd throws outofboundsexception. Because the function returns max sometimes.