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

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

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

Math.IEEEremainder介绍

[英]Returns the remainder of dividing x by y using the IEEE 754 rules. The result is x-round(x/p)*p where round(x/p)is the nearest integer (rounded to even), but without numerical cancellation problems.

Special cases:

  • IEEEremainder((anything), 0) = NaN
  • IEEEremainder(+infinity, (anything)) = NaN
  • IEEEremainder(-infinity, (anything)) = NaN
  • IEEEremainder(NaN, (anything)) = NaN
  • IEEEremainder((anything), NaN) = NaN
  • IEEEremainder(x, +infinity) = x where x is anything but +/-infinity
  • IEEEremainder(x, -infinity) = x where x is anything but +/-infinity
    [中]

代码示例

代码示例来源:origin: apache/mahout

@Override
 public double apply(double a, double b) {
  return Math.IEEEremainder(a, b);
 }
};

代码示例来源:origin: apache/mahout

@Override
 public double apply(double a) {
  return Math.IEEEremainder(a, b);
 }
};

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

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

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

public Object evaluate(Object feature) {
    double arg0;
    double arg1;

    try { // attempt to get value and perform conversion
      arg0 = getExpression(0).evaluate(feature, Double.class).doubleValue();
    } catch (Exception e) {
      // probably a type error
      throw new IllegalArgumentException(
          "Filter Function problem for function IEEEremainder argument #0 - expected type double");
    }

    try { // attempt to get value and perform conversion
      arg1 = getExpression(1).evaluate(feature, Double.class).doubleValue();
    } catch (Exception e) {
      // probably a type error
      throw new IllegalArgumentException(
          "Filter Function problem for function IEEEremainder argument #1 - expected type double");
    }

    return new Double(Math.IEEEremainder(arg0, arg1));
  }
}

代码示例来源:origin: edu.ucar/netcdf

/**
 * put longitude into the range [center +/- 180] deg
 *
 * @param lon    lon to normalize
 * @param center center point
 * @return longitude into the range [center +/- 180] deg
 */
static public double lonNormal(double lon, double center) {
 return center + Math.IEEEremainder(lon - center, 360.0);
}

代码示例来源:origin: org.carrot2/carrot2-core

@Override
 public double apply(double a, double b) {
  return Math.IEEEremainder(a, b);
 }
};

代码示例来源:origin: dhale/jtk

/**
 * Computes the remainder operation on two arguments as prescribed by the 
 * IEEE 754 standard.
 * @param f1 the dividend.
 * @param f2 the divisor.
 * @return the remainder when f1 is divided by f2
 */
public static float IEEEremainder(float f1, float f2) {
 return (float)Math.IEEEremainder(f1,f2);
}

代码示例来源:origin: Unidata/thredds

/**
 * Find difference (lon1 - lon2) normalized so that maximum value is += 180.
 * @param lon1 start
 * @param lon2 end
 * @return
 */
static public double lonDiff(double lon1, double lon2) {
 return Math.IEEEremainder(lon1-lon2, 360.0);
}

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

@Test
  public void testStorableDoubles() {
    for (double d: toIterable(doubles(), 10000)) {
      assertThat(DoubleShard.Compact.isStorable(d),
            equalTo(d > -64 && d < 64 && Scalars.isZero(Math.IEEEremainder(d, 0.5))));
    }
  }
}

代码示例来源:origin: edu.ucar/cdm

/**
 * put longitude into the range [center +/- 180] deg
 *
 * @param lon    lon to normalize
 * @param center center point
 * @return longitude into the range [center +/- 180] deg
 */
static public double lonNormal(double lon, double center) {
 return center + Math.IEEEremainder(lon - center, 360.0);
}

代码示例来源:origin: org.apache.mahout/mahout-math

@Override
 public double apply(double a) {
  return Math.IEEEremainder(a, b);
 }
};

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

/**
 * Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard.
 */
public static double IEEEremainder(double f1, double f2) {
  return java.lang.Math.IEEEremainder(f1, f2);
}

代码示例来源:origin: edu.ucar/unidataCommon

/**
 * put longitude into the range [center +/- 180] deg
 *
 * @param lon    lon to normalize
 * @param center center point
 * @return longitude into the range [center +/- 180] deg
 */
static public double lonNormal(double lon, double center) {
 return center + Math.IEEEremainder(lon - center, 360.0);
}

代码示例来源:origin: org.carrot2/carrot2-core

@Override
 public double apply(double a) {
  return Math.IEEEremainder(a, b);
 }
};

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

double good0 = Math.IEEEremainder(1.0, -1.0);
if (Double.isNaN(good0)) {
  assertTrue(
  assertEquals(
      "IEEEremainder of (1.0,-1.0):",
      (double) Math.IEEEremainder(1.0, -1.0),
      ((Double) IEEEremainderFunction.evaluate(null)).doubleValue(),
      0.00001);
double good1 = Math.IEEEremainder(-1.0, 2.0);
if (Double.isNaN(good1)) {
  assertTrue(
  assertEquals(
      "IEEEremainder of (-1.0,2.0):",
      (double) Math.IEEEremainder(-1.0, 2.0),
      ((Double) IEEEremainderFunction.evaluate(null)).doubleValue(),
      0.00001);
double good2 = Math.IEEEremainder(2.0, -2.0);
if (Double.isNaN(good2)) {
  assertTrue(
  assertEquals(
      "IEEEremainder of (2.0,-2.0):",
      (double) Math.IEEEremainder(2.0, -2.0),
      ((Double) IEEEremainderFunction.evaluate(null)).doubleValue(),
      0.00001);

代码示例来源:origin: org.jruby/jruby-complete

public IRubyObject op_mod(ThreadContext context, double other) {
  // Modelled after c ruby implementation (java /,% not same as ruby)
  double x = value;
  double mod = Math.IEEEremainder(x, other);
  if (other * mod < 0) {
    mod += other;
  }
  return RubyFloat.newFloat(context.runtime, mod);
}

代码示例来源:origin: Esri/geometry-api-java

static private double lam_delta(double lam) {
  double d = Math.IEEEremainder(lam, PE_2PI);
  return (PE_ABS(d) <= PE_PI) ? d : ((d < 0) ? d + PE_2PI : d - PE_2PI);
}

代码示例来源:origin: Unidata/thredds

/**
  * Starting from lon1, find
  * Find difference (lon1 - lon2) normalized so that maximum value is += 180.
  *
  * @param lon1 start
  * @param lon2 end
  * @return
  */
 static public double lonDiff(double lon1, double lon2) {
  return Math.IEEEremainder(lon1 - lon2, 720.0);
 }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public IRubyObject op_mod(ThreadContext context, double other) {
  // Modelled after c ruby implementation (java /,% not same as ruby)
  double x = value;
  double mod = Math.IEEEremainder(x, other);
  if (other * mod < 0) {
    mod += other;
  }
  return RubyFloat.newFloat(getRuntime(), mod);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public IRubyObject op_mod(ThreadContext context, double other) {
  // Modelled after c ruby implementation (java /,% not same as ruby)
  double x = value;
  double mod = Math.IEEEremainder(x, other);
  if (other * mod < 0) {
    mod += other;
  }
  return RubyFloat.newFloat(getRuntime(), mod);
}

相关文章