本文整理汇总了Java中org.jscience.physics.amount.Amount.getMinimumValue方法的典型用法代码示例。如果您正苦于以下问题:Java Amount.getMinimumValue方法的具体用法?Java Amount.getMinimumValue怎么用?Java Amount.getMinimumValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jscience.physics.amount.Amount
的用法示例。
在下文中一共展示了Amount.getMinimumValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNumericValue
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
/**
* This utility method can be used to get a single numerical value for
* an amount. In the case of a an exact amount, this will be the exact value.
* In the case of an inexact amount, this will be the estimated value, or an
* adjusted version thereof to maintain the following property:
*
* AmountUtils.getNumericValue(Amount.valueOf(n, Unit.ONE)) should return n
*
* @param amount
* @return the value of the amount, a Long or a Double (never null)
*/
public static Number getNumericValue(Amount amount) {
if (amount.isExact()) {
return amount.getExactValue();
}
double relativeError = amount.getRelativeError();
double value;
if (relativeError < ERROR_LIMIT) {
value = amount.getMaximumValue();
if (value < 0) {
// for values less than zero, use the minimum value instead
value = amount.getMinimumValue();
} else if (amount.getMinimumValue() <= 0) {
// if the value is zero or above and the minimum is zero or below, zero it is!
return 0L;
}
} else {
value = amount.getEstimatedValue();
}
if (value == (long)value) {
return (long)value;
}
return value;
}
示例2: update
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean update() {
Unit unit = null;
long totalExact = 0;
double totalMin = 0;
double totalMax = 0;
boolean inexact = false;
boolean useCachedValue = true;
Amount newValue = null;
for (Dependency previous : getPrevious()) {
Amount value = (Amount) previous.getValue();
if (value == null || ((Double)value.getEstimatedValue()).isNaN()) {
continue;
}
if (unit == null) {
unit = value.getUnit();
newValue = value;
} else {
value = value.to(unit);
if ((value.getMinimumValue() != 0) || (value.getMaximumValue() != 0)) {
useCachedValue = false;
}
}
if (value.isExact()) {
long exact = value.getExactValue();
long sumLong = totalExact + exact;
double sumDouble = ((double)totalExact) + ((double)exact);
if (sumLong == sumDouble) {
totalExact = sumLong;
} else {
inexact = true;
totalMin += value.getMinimumValue();
totalMax += value.getMaximumValue();
}
} else {
inexact = true;
totalMin += value.getMinimumValue();
totalMax += value.getMaximumValue();
}
}
if (!useCachedValue) {
if (inexact) {
totalMin += totalExact;
totalMax += totalExact;
newValue = Amount.rangeOf(totalMin, totalMax, unit);
} else {
newValue = AmountUtils.toAmount(totalExact, unit);
}
}
Amount oldValue = (Amount) getValue();
if (!equals(oldValue, newValue)) {
setValue(newValue);
return true;
}
return false;
}
示例3: approximatesZero
import org.jscience.physics.amount.Amount; //导入方法依赖的package包/类
/**
* Check to see if the error bounds on the amount contain zero.
*
* @param <Q>
* @param amount
* @return boolean
*/
public static <Q extends Quantity> boolean approximatesZero(Amount<Q> amount) {
return (amount.getMaximumValue() >= 0) && (amount.getMinimumValue() <= 0);
}