當前位置: 首頁>>代碼示例>>Java>>正文


Java FastMath.getExponent方法代碼示例

本文整理匯總了Java中org.apache.commons.math3.util.FastMath.getExponent方法的典型用法代碼示例。如果您正苦於以下問題:Java FastMath.getExponent方法的具體用法?Java FastMath.getExponent怎麽用?Java FastMath.getExponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.math3.util.FastMath的用法示例。


在下文中一共展示了FastMath.getExponent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doubleValue

import org.apache.commons.math3.util.FastMath; //導入方法依賴的package包/類
/**
 * <p>
 * Gets the fraction as a {@code double}. This calculates the fraction as
 * the numerator divided by denominator.
 * </p>
 *
 * @return the fraction as a {@code double}
 * @see java.lang.Number#doubleValue()
 */
@Override
public double doubleValue() {
    double result = numerator.doubleValue() / denominator.doubleValue();
    if (Double.isNaN(result)) {
        // Numerator and/or denominator must be out of range:
        // Calculate how far to shift them to put them in range.
        int shift = FastMath.max(numerator.bitLength(),
                                 denominator.bitLength()) - FastMath.getExponent(Double.MAX_VALUE);
        result = numerator.shiftRight(shift).doubleValue() /
            denominator.shiftRight(shift).doubleValue();
    }
    return result;
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:23,代碼來源:BigFraction.java

示例2: floatValue

import org.apache.commons.math3.util.FastMath; //導入方法依賴的package包/類
/**
 * <p>
 * Gets the fraction as a {@code float}. This calculates the fraction as
 * the numerator divided by denominator.
 * </p>
 *
 * @return the fraction as a {@code float}.
 * @see java.lang.Number#floatValue()
 */
@Override
public float floatValue() {
    float result = numerator.floatValue() / denominator.floatValue();
    if (Double.isNaN(result)) {
        // Numerator and/or denominator must be out of range:
        // Calculate how far to shift them to put them in range.
        int shift = FastMath.max(numerator.bitLength(),
                                 denominator.bitLength()) - FastMath.getExponent(Float.MAX_VALUE);
        result = numerator.shiftRight(shift).floatValue() /
            denominator.shiftRight(shift).floatValue();
    }
    return result;
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:23,代碼來源:BigFraction.java

示例3: hypot

import org.apache.commons.math3.util.FastMath; //導入方法依賴的package包/類
/** {@inheritDoc} */
public SparseGradient hypot(final SparseGradient y) {
    if (Double.isInfinite(value) || Double.isInfinite(y.value)) {
        return createConstant(Double.POSITIVE_INFINITY);
    } else if (Double.isNaN(value) || Double.isNaN(y.value)) {
        return createConstant(Double.NaN);
    } else {

        final int expX = FastMath.getExponent(value);
        final int expY = FastMath.getExponent(y.value);
        if (expX > expY + 27) {
            // y is negligible with respect to x
            return abs();
        } else if (expY > expX + 27) {
            // x is negligible with respect to y
            return y.abs();
        } else {

            // find an intermediate scale to avoid both overflow and underflow
            final int middleExp = (expX + expY) / 2;

            // scale parameters without losing precision
            final SparseGradient scaledX = scalb(-middleExp);
            final SparseGradient scaledY = y.scalb(-middleExp);

            // compute scaled hypotenuse
            final SparseGradient scaledH =
                    scaledX.multiply(scaledX).add(scaledY.multiply(scaledY)).sqrt();

            // remove scaling
            return scaledH.scalb(middleExp);

        }

    }
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:37,代碼來源:SparseGradient.java

示例4: getExponent

import org.apache.commons.math3.util.FastMath; //導入方法依賴的package包/類
/**
 * Return the exponent of the instance value, removing the bias.
 * <p>
 * For double numbers of the form 2<sup>x</sup>, the unbiased
 * exponent is exactly x.
 * </p>
 * @return exponent for instance in IEEE754 representation, without bias
 */
public int getExponent() {
    return FastMath.getExponent(data[0]);
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:12,代碼來源:DerivativeStructure.java


注:本文中的org.apache.commons.math3.util.FastMath.getExponent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。