java.lang.Math.copySign()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(203)

本文整理了Java中java.lang.Math.copySign()方法的一些代码示例,展示了Math.copySign()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Math.copySign()方法的具体详情如下:
包路径:java.lang.Math
类名称:Math
方法名:copySign

Math.copySign介绍

[英]Returns a double with the given magnitude and the sign of sign. If sign is NaN, the sign of the result is arbitrary. If you need a determinate sign in such cases, use StrictMath.copySign.
[中]返回具有给定大小和符号的双精度数。如果符号为NaN,则结果的符号是任意的。如果在这种情况下需要确定符号,请使用StrictMath。文案。

代码示例

代码示例来源:origin: apache/incubator-druid

@Override
 protected ExprEval eval(double x, double y)
 {
  return ExprEval.of(Math.copySign(x, y));
 }
}

代码示例来源:origin: runelite/runelite

/**
 * Approximation of erf 'Gauss error function' which is used to calculate
 * the cumulative distribution of a gaussian distribution.
 * This is used to simulate a large kernel gaussian blur without having
 * to sample the same chunk multiple times.
 */
private double erf(double x)
{
  double ax = Math.abs(x);
  double t = 1.d / (1.d + (ax * .3275911d));
  double y = 1.d - ((((((1.061405429d * t) - 1.453152027d) * t) + 1.421413741d) * t - 0.284496736d) * t + 0.254829592d) * t * Math.exp(-ax * ax);
  return Math.copySign(y, x);
}

代码示例来源:origin: google/guava

return Math.copySign(a - b, 1.0) <= tolerance

代码示例来源:origin: prestodb/presto

return Math.copySign(a - b, 1.0) <= tolerance

代码示例来源:origin: google/j2objc

return Math.copySign(a - b, 1.0) <= tolerance

代码示例来源:origin: wildfly/wildfly

return Math.copySign(a - b, 1.0) <= tolerance

代码示例来源:origin: google/guava

return x + copySign(0.5, x);
} else {
 return z;

代码示例来源:origin: prestodb/presto

return x + copySign(0.5, x);
} else {
 return z;

代码示例来源:origin: google/j2objc

return x + copySign(0.5, x);
} else {
 return z;

代码示例来源:origin: line/armeria

if (qValue > matchQ) {
  isBetter = true;
} else if (Math.copySign(qValue - matchQ, 1.0f) <= 0.0001f) {
  if (matchNumWildcards > numWildcards) {
    isBetter = true;

代码示例来源:origin: wildfly/wildfly

return x + copySign(0.5, x);
} else {
 return z;

代码示例来源:origin: SpongePowered/SpongeAPI

final double txMax;
final Vector3d xNormal;
if (Math.copySign(1, direction.getX()) > 0) {
  txMin = (this.min.getX() - start.getX()) / direction.getX();
  txMax = (this.max.getX() - start.getX()) / direction.getX();
final double tyMax;
final Vector3d yNormal;
if (Math.copySign(1, direction.getY()) > 0) {
  tyMin = (this.min.getY() - start.getY()) / direction.getY();
  tyMax = (this.max.getY() - start.getY()) / direction.getY();
final double tzMax;
final Vector3d zNormal;
if (Math.copySign(1, direction.getZ()) > 0) {
  tzMin = (this.min.getZ() - start.getZ()) / direction.getZ();
  tzMax = (this.max.getZ() - start.getZ()) / direction.getZ();

代码示例来源:origin: com.github.haifengl/smile-math

/**
 * Returns the first floating-point argument with the sign of the second
 * floating-point argument.
 */
public static double copySign(double magnitude, double sign) {
  return java.lang.Math.copySign(magnitude, sign);
}

代码示例来源:origin: com.github.haifengl/smile-math

/**
 * Returns the first floating-point argument with the sign of the second
 * floating-point argument.
 */
public static float copySign(float magnitude, float sign) {
  return java.lang.Math.copySign(magnitude, sign);
}

代码示例来源:origin: allr/purdue-fastr

public static double convertNaN(double d) {
  if (Double.isNaN(d)) {
    return Math.copySign(0, d);
  } else {
    return d;
  }
}

代码示例来源:origin: us.ihmc/ihmc-avatar-interfaces

public static double adjustCoordinatesToResolution(double coord, double resolution)
{
 long n = Math.round((Math.abs(coord) - 0.5 * resolution) / resolution);
 double output = n * resolution - 0.5 * resolution;
 return Math.copySign(output, coord);
}

代码示例来源:origin: us.ihmc/IHMCAvatarInterfaces

public static double adjustCoordinatesToResolution(double coord, double resolution)
{
 long n = Math.round((Math.abs(coord) - 0.5 * resolution) / resolution);
 double output = n * resolution - 0.5 * resolution;
 return Math.copySign(output, coord);
}

代码示例来源:origin: org.apache.druid/druid-common

@Override
 protected ExprEval eval(double x, double y)
 {
  return ExprEval.of(Math.copySign(x, y));
 }
}

代码示例来源:origin: geogebra/geogebra

/** {@inheritDoc}
 * @since 3.2
 */
public Decimal64 copySign(final Decimal64 sign) {
  return new Decimal64(Math.copySign(value, sign.value));
}

代码示例来源:origin: geogebra/geogebra

/** {@inheritDoc}
 * @since 3.2
 */
public Decimal64 copySign(final double sign) {
  return new Decimal64(Math.copySign(value, sign));
}

相关文章