当前位置: 首页>>代码示例>>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;未经允许,请勿转载。