@@ -41,7 +41,8 @@ private NumericUtil() {
4141 * precision is not reduced, but the value can easily used as a long. The
4242 * sort order (including {@link Double#NaN}) is defined by
4343 * {@link Double#compareTo}; {@code NaN} is greater than positive infinity.
44- *
44+ * @param val input double value
45+ * @return output sortable long value
4546 * @see #sortableLongToDouble
4647 */
4748 public static long doubleToSortableLong (double val ) {
@@ -50,7 +51,8 @@ public static long doubleToSortableLong(double val) {
5051
5152 /**
5253 * Converts a sortable <code>long</code> back to a <code>double</code>.
53- *
54+ * @param val input double value
55+ * @return output sortable long value
5456 * @see #doubleToSortableLong
5557 */
5658 public static double sortableLongToDouble (long val ) {
@@ -65,7 +67,8 @@ public static double sortableLongToDouble(long val) {
6567 * is not reduced, but the value can easily used as an int. The sort order
6668 * (including {@link Float#NaN}) is defined by {@link Float#compareTo};
6769 * {@code NaN} is greater than positive infinity.
68- *
70+ * @param val input float value
71+ * @return output sortable int value
6972 * @see #sortableIntToFloat
7073 */
7174 public static int floatToSortableInt (float val ) {
@@ -74,7 +77,8 @@ public static int floatToSortableInt(float val) {
7477
7578 /**
7679 * Converts a sortable <code>int</code> back to a <code>float</code>.
77- *
80+ * @param val input int value
81+ * @return output sortable float value
7882 * @see #floatToSortableInt
7983 */
8084 public static float sortableIntToFloat (int val ) {
@@ -84,6 +88,8 @@ public static float sortableIntToFloat(int val) {
8488 /**
8589 * Converts IEEE 754 representation of a double to sortable order (or back
8690 * to the original)
91+ * @param bits The long format of a double value
92+ * @return The sortable long value
8793 */
8894 public static long sortableDoubleBits (long bits ) {
8995 return bits ^ (bits >> 63 ) & 0x7fffffffffffffffL ;
@@ -92,13 +98,13 @@ public static long sortableDoubleBits(long bits) {
9298 /**
9399 * Converts IEEE 754 representation of a float to sortable order (or back to
94100 * the original)
101+ * @param bits The int format of an float value
102+ * @return The sortable int value
95103 */
96104 public static int sortableFloatBits (int bits ) {
97105 return bits ^ (bits >> 31 ) & 0x7fffffff ;
98106 }
99107
100- /*************************************************************************/
101-
102108 public static byte [] numberToSortableBytes (Number number ) {
103109 if (number instanceof Long ) {
104110 return longToBytes (number .longValue ());
@@ -137,8 +143,6 @@ public static Number sortableBytesToNumber(byte[] bytes, Class<?> clazz) {
137143 return null ;
138144 }
139145
140- /*************************************************************************/
141-
142146 public static byte [] longToBytes (long value ) {
143147 ByteBuffer buffer = ByteBuffer .allocate (Long .BYTES );
144148 buffer .putLong (value );
@@ -161,8 +165,6 @@ public static int bytesToInt(byte[] bytes) {
161165 return ByteBuffer .wrap (bytes ).getInt ();
162166 }
163167
164- /*************************************************************************/
165-
166168 public static boolean isNumber (Object value ) {
167169 if (value == null ) {
168170 return false ;
@@ -174,8 +176,6 @@ public static boolean isNumber(Class<?> clazz) {
174176 return Number .class .isAssignableFrom (clazz );
175177 }
176178
177- /*************************************************************************/
178-
179179 public static Object convertToNumber (Object value ) {
180180 if (!isNumber (value ) && value != null ) {
181181 if (value instanceof Date ) {
@@ -193,6 +193,10 @@ public static Object convertToNumber(Object value) {
193193 * or it can be converted to a BigDecimal
194194 * @param first might be number or string
195195 * @param second must be number
196+ * @return the value 0 if first is numerically equal to second;
197+ * a value less than 0 if first is numerically less than
198+ * second; and a value greater than 0 if first is
199+ * numerically greater than second.
196200 */
197201 @ SuppressWarnings ("unchecked" )
198202 public static int compareNumber (Object first , Number second ) {
0 commit comments