Java Utililty Methods Number Copy Sign

List of utility methods to do Number Copy Sign

Description

The list of methods to do Number Copy Sign are organized into topic(s).

Method

doublecopySign(Double magnitude, Double sign)
Copy sign.
return Math.copySign(magnitude, sign);
doublecopySign(double magnitude, double sign)
copy Sign
if (sign < 0) {
    return (magnitude < 0) ? magnitude : -magnitude;
} else {
    return (magnitude > 0) ? magnitude : -magnitude;
doublecopySign(double x, double y)
Returns one value with the sign of another (like copysign).
return y >= 0.0 ? Math.abs(x) : -Math.abs(x);
doublecopySign(final double magnitude, final double sign)
Copies the sign of sign into magnitude.
final long m = Double.doubleToLongBits(magnitude);
final long s = Double.doubleToLongBits(sign);
if (0 <= (m ^ s))
    return -magnitude;
return magnitude; 
doublecopysign(final double x, final double y)
copysign
return (y < 0.0D && x > 0.0D) ? -x : ((y > 0.0D && x < 0.0D) ? -x : x);
doublecopySign(final double x, final double y)
copy Sign
return Double.longBitsToDouble((Double.doubleToLongBits(x) & 0x7fffffffffffffffL)
        | (Double.doubleToLongBits(y) & 0x8000000000000000L));