本文整理汇总了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);
}