code: public static float copySign(float magnitude, float sign){
          int m = Float.floatToIntBits(magnitude);
          int s = Float.floatToIntBits(sign);
          if ((m >= 0 && s >= 0) || (m < 0 && s < 0)) { // Sign is currently OK
              return magnitude;
          }
          return -magnitude; // flip sign
      }
docs: Returns the first argument with the sign of the second argument.
  A NaN {@code sign} argument is treated as positive.
  
  @param magnitude the value to return
  @param sign the sign for the returned value
  @return the magnitude with the same sign as the {@code sign} argument