本文整理匯總了Java中org.apache.commons.lang.math.NumberUtils.compare方法的典型用法代碼示例。如果您正苦於以下問題:Java NumberUtils.compare方法的具體用法?Java NumberUtils.compare怎麽用?Java NumberUtils.compare使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang.math.NumberUtils
的用法示例。
在下文中一共展示了NumberUtils.compare方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: append
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
* <p>Appends to the <code>builder</code> the comparison of
* two <code>double</code>s.</p>
*
* <p>This handles NaNs, Infinities, and <code>-0.0</code>.</p>
*
* <p>It is compatible with the hash code generated by
* <code>HashCodeBuilder</code>.</p>
*
* @param lhs left-hand value
* @param rhs right-hand value
* @return this - used to chain append calls
*/
public CompareToBuilder append(double lhs, double rhs) {
if (comparison != 0) {
return this;
}
comparison = NumberUtils.compare(lhs, rhs);
return this;
}
示例2: compareTo
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
* Compares this mutable to another in ascending order.
*
* @param obj the other mutable to compare to, not null
* @return negative if this is less, zero if equal, positive if greater
* @throws ClassCastException if the argument is not a MutableDouble
*/
public int compareTo(Object obj) {
MutableDouble other = (MutableDouble) obj;
double anotherVal = other.value;
return NumberUtils.compare(value, anotherVal);
}
示例3: compareTo
import org.apache.commons.lang.math.NumberUtils; //導入方法依賴的package包/類
/**
* Compares this mutable to another in ascending order.
*
* @param obj the other mutable to compare to, not null
* @return negative if this is less, zero if equal, positive if greater
*/
public int compareTo(Object obj) {
MutableFloat other = (MutableFloat) obj;
float anotherVal = other.value;
return NumberUtils.compare(value, anotherVal);
}