Double has a compareTo method that describes a natural ordering for double
values. But if I'm working with primitive values I can't use them without
creating objects. If I'm writing my own sort method for a double array,
for example, I will have to recreate the logic of compareTo in my method,
since
if (d1 < d2) ...
doesn't do the right thing in many cases. I would like a compare method,
as in
/**
* Compares the two double values, returning the equivalent of
* new Double(d1).compareTo(new Double(d2))
*/
public static int compare(double d1, double d2) { ... }
And an equivalent one for Float.
values. But if I'm working with primitive values I can't use them without
creating objects. If I'm writing my own sort method for a double array,
for example, I will have to recreate the logic of compareTo in my method,
since
if (d1 < d2) ...
doesn't do the right thing in many cases. I would like a compare method,
as in
/**
* Compares the two double values, returning the equivalent of
* new Double(d1).compareTo(new Double(d2))
*/
public static int compare(double d1, double d2) { ... }
And an equivalent one for Float.