当前位置: 首页>>代码示例>>Java>>正文


Java Amount.getMaximumValue方法代码示例

本文整理汇总了Java中org.jscience.physics.amount.Amount.getMaximumValue方法的典型用法代码示例。如果您正苦于以下问题:Java Amount.getMaximumValue方法的具体用法?Java Amount.getMaximumValue怎么用?Java Amount.getMaximumValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jscience.physics.amount.Amount的用法示例。


在下文中一共展示了Amount.getMaximumValue方法的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;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:35,代码来源:AmountUtils.java

示例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;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:58,代码来源:SummingDependency.java

示例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);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:11,代码来源:AmountUtils.java


注:本文中的org.jscience.physics.amount.Amount.getMaximumValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。