Java Number Copy Sign copySign(final double x, final double y)

Here you can find the source of copySign(final double x, final double y)

Description

copy Sign

License

Open Source License

Declaration

public static final double copySign(final double x, final double y) 

Method Source Code

//package com.java2s;

public class Main {
    public static final double copySign(final double x, final double y) {
        //__HI(x) = (__HI(x)&0x7fffffff)|(__HI(y)&0x80000000);
        // The below is actually about 30% faster than doing greater/less comparisons.
        return Double.longBitsToDouble((Double.doubleToLongBits(x) & 0x7fffffffffffffffL)
                | (Double.doubleToLongBits(y) & 0x8000000000000000L));
    }//from w  w w  .  j a  v a2  s  .  co m

    /**
     * Please update your code to use copySign
     * @param x
     * @param y
     * @return copySign(x,y)
     * @deprecated Please update your code to use copySign
     */
    public static final double copysign(final double x, final double y) {
        return copySign(x, y);
    }
}

Related

  1. copySign(Double magnitude, Double sign)
  2. copySign(double magnitude, double sign)
  3. copySign(double x, double y)
  4. copySign(final double magnitude, final double sign)
  5. copysign(final double x, final double y)