Example usage for java.lang Double doubleToLongBits

List of usage examples for java.lang Double doubleToLongBits

Introduction

In this page you can find the example usage for java.lang Double doubleToLongBits.

Prototype

@HotSpotIntrinsicCandidate
public static long doubleToLongBits(double value) 

Source Link

Document

Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout.

Usage

From source file:com.tibbo.linkserver.plugin.device.file.item.NumericItem.java

public short[] valueToShorts(Number value) {
    if (dataType == 2 || dataType == 3) {
        return (new short[] { toShort(value) });
    }//from w  w  w.  j a  va  2 s.c  o  m
    if (dataType == 16) {
        short s = toShort(value);
        return (new short[] {
                (short) ((s / 1000) % 10 << 12 | (s / 100) % 10 << 8 | (s / 10) % 10 << 4 | s % 10) });
    }
    if (dataType == 4 || dataType == 5) {
        int i = toInt(value);
        return (new short[] { (short) (i >> 16), (short) i });
    }
    if (dataType == 6 || dataType == 7) {
        int i = toInt(value);
        return (new short[] { (short) i, (short) (i >> 16) });
    }
    if (dataType == 8) {
        int i = Float.floatToIntBits(value.floatValue());
        return (new short[] { (short) (i >> 16), (short) i });
    }
    if (dataType == 9) {
        int i = Float.floatToIntBits(value.floatValue());
        return (new short[] { (short) i, (short) (i >> 16) });
    }
    if (dataType == 17) {
        int i = toInt(value);
        return (new short[] {
                (short) ((i / 0x989680) % 10 << 12 | (i / 0xf4240) % 10 << 8 | (i / 0x186a0) % 10 << 4
                        | (i / 10000) % 10),
                (short) ((i / 1000) % 10 << 12 | (i / 100) % 10 << 8 | (i / 10) % 10 << 4 | i % 10) });
    }
    if (dataType == 10 || dataType == 11) {
        long l = value.longValue();
        return (new short[] { (short) (int) (l >> 48), (short) (int) (l >> 32), (short) (int) (l >> 16),
                (short) (int) l });
    }
    if (dataType == 12 || dataType == 13) {
        long l = value.longValue();
        return (new short[] { (short) (int) l, (short) (int) (l >> 16), (short) (int) (l >> 32),
                (short) (int) (l >> 48) });
    }
    if (dataType == 14) {
        long l = Double.doubleToLongBits(value.doubleValue());
        return (new short[] { (short) (int) (l >> 48), (short) (int) (l >> 32), (short) (int) (l >> 16),
                (short) (int) l });
    }
    if (dataType == 15) {
        long l = Double.doubleToLongBits(value.doubleValue());
        return (new short[] { (short) (int) l, (short) (int) (l >> 16), (short) (int) (l >> 32),
                (short) (int) (l >> 48) });
    } else {
        throw new RuntimeException(
                (new StringBuilder()).append("Unsupported data type: ").append(dataType).toString());
    }
}

From source file:com.opengamma.maths.lowlevelapi.datatypes.primitive.CompressedSparseColumnFormatMatrix.java

@Override
public double[] getRowElements(int index) { // getting rows in CSC form is generally bad
    double[] tmp = new double[_cols];
    double val;
    int ptr = 0;/*  w w  w. j  a  v  a2 s  .c  o m*/
    for (int i = 0; i < _cols; i++) {
        val = this.getEntry(index, i);
        if (Double.doubleToLongBits(val) != 0) {
            tmp[ptr] = val;
            ptr++;
        }

    }
    return Arrays.copyOfRange(tmp, 0, ptr);
}

From source file:com.opengamma.analytics.financial.model.volatility.BlackFormula.java

@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }//from ww  w. j  a  v  a2s.c om
    if (!(obj instanceof BlackFormula)) {
        return false;
    }
    final BlackFormula other = (BlackFormula) obj;
    if (Double.doubleToLongBits(_expiry) != Double.doubleToLongBits(other._expiry)) {
        return false;
    }
    if (Double.doubleToLongBits(_forward) != Double.doubleToLongBits(other._forward)) {
        return false;
    }
    if (Double.doubleToLongBits(_strike) != Double.doubleToLongBits(other._strike)) {
        return false;
    }
    if (_isCall != other._isCall) {
        return false;
    }
    if (!ObjectUtils.equals(_fwdMtm, other._fwdMtm)) {
        return false;
    }
    if (!ObjectUtils.equals(_lognormalVol, other._lognormalVol)) {
        return false;
    }
    return true;
}

From source file:com.opengamma.analytics.financial.instrument.payment.CouponArithmeticAverageONSpreadSimplifiedDefinition.java

@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }// w  ww  . j av  a2  s. co m
    if (!super.equals(obj)) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    final CouponArithmeticAverageONSpreadSimplifiedDefinition other = (CouponArithmeticAverageONSpreadSimplifiedDefinition) obj;
    if (!ObjectUtils.equals(_index, other._index)) {
        return false;
    }
    if (Double.doubleToLongBits(_spread) != Double.doubleToLongBits(other._spread)) {
        return false;
    }
    if (Double.doubleToLongBits(_spreadAmount) != Double.doubleToLongBits(other._spreadAmount)) {
        return false;
    }
    return true;
}

From source file:com.opengamma.analytics.financial.instrument.payment.CouponONSpreadSimplifiedDefinition.java

@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }//from ww  w .  j  a v  a  2 s  .co  m
    if (!super.equals(obj)) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    final CouponONSpreadSimplifiedDefinition other = (CouponONSpreadSimplifiedDefinition) obj;
    if (Double.doubleToLongBits(_fixingPeriodAccrualFactor) != Double
            .doubleToLongBits(other._fixingPeriodAccrualFactor)) {
        return false;
    }
    if (!ObjectUtils.equals(_fixingPeriodEndDate, other._fixingPeriodEndDate)) {
        return false;
    }
    if (!ObjectUtils.equals(_fixingPeriodStartDate, other._fixingPeriodStartDate)) {
        return false;
    }
    if (!ObjectUtils.equals(_index, other._index)) {
        return false;
    }
    if (Double.doubleToLongBits(_spread) != Double.doubleToLongBits(other._spread)) {
        return false;
    }
    if (Double.doubleToLongBits(_spreadAmount) != Double.doubleToLongBits(other._spreadAmount)) {
        return false;
    }
    return true;
}

From source file:be.ceau.chart.color.Color.java

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    Color other = (Color) obj;
    if (Double.doubleToLongBits(alpha) != Double.doubleToLongBits(other.alpha))
        return false;
    if (b != other.b)
        return false;
    if (g != other.g)
        return false;
    if (r != other.r)
        return false;
    return true;/*from  ww  w  . jav  a2s.  com*/
}

From source file:com.opengamma.analytics.math.interpolation.data.Interpolator1DCubicSplineDataBundle.java

@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }/*from  w  w  w  . ja v a  2s  .com*/
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    final Interpolator1DCubicSplineDataBundle other = (Interpolator1DCubicSplineDataBundle) obj;
    if (!ObjectUtils.equals(_underlyingData, other._underlyingData)) {
        return false;
    }
    if (Double.doubleToLongBits(_leftFirstDev) != Double.doubleToLongBits(other._leftFirstDev)) {
        return false;
    }
    if (_leftNatural != other._leftNatural) {
        return false;
    }
    if (Double.doubleToLongBits(_rightFirstDev) != Double.doubleToLongBits(other._rightFirstDev)) {
        return false;
    }
    if (_rightNatural != other._rightNatural) {
        return false;
    }
    return true;
}

From source file:com.opengamma.analytics.financial.equity.variance.definition.VarianceSwapDefinition.java

@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((_currency == null) ? 0 : _currency.hashCode());
    result = prime * result + ((_obsEndDate == null) ? 0 : _obsEndDate.hashCode());
    result = prime * result + ((_obsStartDate == null) ? 0 : _obsStartDate.hashCode());
    result = prime * result + ((_settlementDate == null) ? 0 : _settlementDate.hashCode());
    long temp;//  ww  w .  j  a v a  2 s . co m
    temp = Double.doubleToLongBits(_volNotional);
    result = prime * result + (int) (temp ^ (temp >>> 32));
    temp = Double.doubleToLongBits(_volStrike);
    result = prime * result + (int) (temp ^ (temp >>> 32));
    return result;
}

From source file:com.opengamma.analytics.financial.interestrate.future.derivative.FederalFundsFutureSecurity.java

@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }//from w  w  w . j a  v  a  2 s  . com
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    final FederalFundsFutureSecurity other = (FederalFundsFutureSecurity) obj;
    if (Double.doubleToLongBits(_accruedInterest) != Double.doubleToLongBits(other._accruedInterest)) {
        return false;
    }
    if (Double.doubleToLongBits(_notional) != Double.doubleToLongBits(other._notional)) {
        return false;
    }
    if (Double.doubleToLongBits(_paymentAccrualFactor) != Double
            .doubleToLongBits(other._paymentAccrualFactor)) {
        return false;
    }
    if (!Arrays.equals(_fixingPeriodAccrualFactor, other._fixingPeriodAccrualFactor)) {
        return false;
    }
    if (!Arrays.equals(_fixingPeriodTime, other._fixingPeriodTime)) {
        return false;
    }
    if (!ObjectUtils.equals(_index, other._index)) {
        return false;
    }
    if (!ObjectUtils.equals(_name, other._name)) {
        return false;
    }
    return true;
}

From source file:com.opengamma.maths.lowlevelapi.datatypes.primitive.MatrixPrimitiveUtils.java

/**
 * Boolean on whether a matrix is upper Hessenberg
 * @param aMatrix an array of arrays representation of the matrix to be tested.
 * @return boolean, true if matrix is upper Hessenberg, false if matrix is not.
 * @throws IllegalArgumentException//w  ww  .jav  a 2  s.  c om
 */
public static boolean isUpperHessenberg(double[][] aMatrix) throws IllegalArgumentException {
    if (!isSquare(aMatrix)) {
        throw new IllegalArgumentException(
                "Matrix is not square so the notion of Upper Hessenberg isn't clear cut enough to be implemented");
    }
    int rows = aMatrix.length;

    for (int i = 2; i < rows; i++) {
        for (int j = 0; j < i - 1; j++) {
            if (Double.doubleToLongBits(aMatrix[i][j]) != 0) {
                return false;
            }
        }
    }
    return true;
}