List of usage examples for java.lang Double doubleToLongBits
@HotSpotIntrinsicCandidate public static long doubleToLongBits(double value)
From source file:Primitives.java
/** * Test the equality of two doubles by converting their values into IEEE 754 * floating-point "double format" long values. * /*from w w w.j a v a 2 s. com*/ * @param a * Double to check equality with. * @param b * Double to check equality with. * @return True if a equals b. */ public static boolean equals(final double a, final double b) { return Double.doubleToLongBits(a) == Double.doubleToLongBits(b); }
From source file:Main.java
/** * Get the next machine representable number after a number, moving * in the direction of another number.// w ww.ja v a 2s . c om * <p> * If <code>direction</code> is greater than or equal to<code>d</code>, * the smallest machine representable number strictly greater than * <code>d</code> is returned; otherwise the largest representable number * strictly less than <code>d</code> is returned.</p> * <p> * If <code>d</code> is NaN or Infinite, it is returned unchanged.</p> * * @param d base number * @param direction (the only important thing is whether * direction is greater or smaller than d) * @return the next machine representable number in the specified direction * @since 1.2 */ public static double nextAfter(double d, double direction) { // handling of some important special cases if (Double.isNaN(d) || Double.isInfinite(d)) { return d; } else if (d == 0) { return (direction < 0) ? -Double.MIN_VALUE : Double.MIN_VALUE; } // special cases MAX_VALUE to infinity and MIN_VALUE to 0 // are handled just as normal numbers // split the double in raw components long bits = Double.doubleToLongBits(d); long sign = bits & 0x8000000000000000L; long exponent = bits & 0x7ff0000000000000L; long mantissa = bits & 0x000fffffffffffffL; if (d * (direction - d) >= 0) { // we should increase the mantissa if (mantissa == 0x000fffffffffffffL) { return Double.longBitsToDouble(sign | (exponent + 0x0010000000000000L)); } else { return Double.longBitsToDouble(sign | exponent | (mantissa + 1)); } } else { // we should decrease the mantissa if (mantissa == 0L) { return Double.longBitsToDouble(sign | (exponent - 0x0010000000000000L) | 0x000fffffffffffffL); } else { return Double.longBitsToDouble(sign | exponent | (mantissa - 1)); } } }
From source file:Main.java
public static byte[] doubleToBytesBE(double d, byte[] bytes, int off) { return longToBytesBE(Double.doubleToLongBits(d), bytes, off); }
From source file:com.opengamma.analytics.financial.simpleinstruments.pricing.SimpleFutureDataBundle.java
@Override public int hashCode() { final int prime = 31; int result = 1; long temp;// www . j a v a2 s .c o m temp = Double.doubleToLongBits(_costOfCarry); result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(_spot); result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + _yieldCurve.hashCode(); return result; }
From source file:com.opengamma.analytics.financial.model.option.pricing.analytic.formula.CEVFunctionData.java
@Override public int hashCode() { final int prime = 31; int result = 1; long temp;//from w ww . j a v a2s.c o m temp = Double.doubleToLongBits(_beta); result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(_forward); result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(_numeraire); result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(_volatility); result = prime * result + (int) (temp ^ (temp >>> 32)); return result; }
From source file:com.opengamma.analytics.financial.simpleinstruments.pricing.SimpleFXFutureDataBundle.java
@Override public int hashCode() { final int prime = 31; int result = 1; long temp;// w ww . ja v a 2 s . c o m temp = Double.doubleToLongBits(_spot); result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + _payYieldCurve.hashCode(); result = prime * result + _receiveYieldCurve.hashCode(); return result; }
From source file:com.opengamma.analytics.financial.trade.OptionTradeData.java
@Override public boolean equals(final Object obj) { if (this == obj) { return true; }/* w w w . j a v a 2 s .co m*/ if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final OptionTradeData other = (OptionTradeData) obj; if (Double.doubleToLongBits(_numberOfContracts) != Double.doubleToLongBits(other._numberOfContracts)) { return false; } if (Double.doubleToLongBits(_pointValue) != Double.doubleToLongBits(other._pointValue)) { return false; } return true; }
From source file:com.bigml.histogram.Gap.java
@Override public boolean equals(Object obj) { if (obj == null) { return false; }/*from w ww .ja v a2 s . c o m*/ if (getClass() != obj.getClass()) { return false; } final Gap other = (Gap) obj; if (Double.doubleToLongBits(this._weight) != Double.doubleToLongBits(other._weight)) { return false; } if (this._startBin != other._startBin && (this._startBin == null || !this._startBin.equals(other._startBin))) { return false; } return true; }
From source file:com.opengamma.analytics.financial.forex.derivative.Forex.java
/** * Constructor from two fixed payments. The payments should take place on the same date. The sign of the amounts should be opposite. * @param paymentCurrency1 The first currency payment. * @param paymentCurrency2 The second currency payment. *///from ww w .ja va2 s. co m public Forex(final PaymentFixed paymentCurrency1, final PaymentFixed paymentCurrency2) { Validate.notNull(paymentCurrency1, "Payment 1"); Validate.notNull(paymentCurrency2, "Payment 2"); Validate.isTrue(Double.doubleToLongBits(paymentCurrency1.getPaymentTime()) == Double .doubleToLongBits(paymentCurrency2.getPaymentTime()), "Payments on different time"); Validate.isTrue((paymentCurrency1.getAmount() * paymentCurrency2.getAmount()) <= 0, "Payments with same sign"); Validate.isTrue(!paymentCurrency1.getCurrency().equals(paymentCurrency2.getCurrency()), "same currency"); this._paymentCurrency1 = paymentCurrency1; this._paymentCurrency2 = paymentCurrency2; }
From source file:com.mgmtp.perfload.loadprofiles.ui.util.Point.java
@Override public int hashCode() { final int prime = 31; int result = 1; long temp;//from w w w . j a v a 2s . c om temp = Double.doubleToLongBits(x); result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(y); result = prime * result + (int) (temp ^ (temp >>> 32)); return result; }