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

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

本文整理了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

  1. @Override
  2. public double apply(double a, double b) {
  3. return Math.IEEEremainder(a, b);
  4. }
  5. };

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

  1. @Override
  2. public double apply(double a) {
  3. return Math.IEEEremainder(a, b);
  4. }
  5. };

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

  1. @Override
  2. protected ExprEval eval(double x, double y)
  3. {
  4. return ExprEval.of(Math.IEEEremainder(x, y));
  5. }
  6. }

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

  1. public Object evaluate(Object feature) {
  2. double arg0;
  3. double arg1;
  4. try { // attempt to get value and perform conversion
  5. arg0 = getExpression(0).evaluate(feature, Double.class).doubleValue();
  6. } catch (Exception e) {
  7. // probably a type error
  8. throw new IllegalArgumentException(
  9. "Filter Function problem for function IEEEremainder argument #0 - expected type double");
  10. }
  11. try { // attempt to get value and perform conversion
  12. arg1 = getExpression(1).evaluate(feature, Double.class).doubleValue();
  13. } catch (Exception e) {
  14. // probably a type error
  15. throw new IllegalArgumentException(
  16. "Filter Function problem for function IEEEremainder argument #1 - expected type double");
  17. }
  18. return new Double(Math.IEEEremainder(arg0, arg1));
  19. }
  20. }

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

  1. /**
  2. * put longitude into the range [center +/- 180] deg
  3. *
  4. * @param lon lon to normalize
  5. * @param center center point
  6. * @return longitude into the range [center +/- 180] deg
  7. */
  8. static public double lonNormal(double lon, double center) {
  9. return center + Math.IEEEremainder(lon - center, 360.0);
  10. }

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

  1. @Override
  2. public double apply(double a, double b) {
  3. return Math.IEEEremainder(a, b);
  4. }
  5. };

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

  1. /**
  2. * Computes the remainder operation on two arguments as prescribed by the
  3. * IEEE 754 standard.
  4. * @param f1 the dividend.
  5. * @param f2 the divisor.
  6. * @return the remainder when f1 is divided by f2
  7. */
  8. public static float IEEEremainder(float f1, float f2) {
  9. return (float)Math.IEEEremainder(f1,f2);
  10. }

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

  1. /**
  2. * Find difference (lon1 - lon2) normalized so that maximum value is += 180.
  3. * @param lon1 start
  4. * @param lon2 end
  5. * @return
  6. */
  7. static public double lonDiff(double lon1, double lon2) {
  8. return Math.IEEEremainder(lon1-lon2, 360.0);
  9. }

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

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

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

  1. /**
  2. * put longitude into the range [center +/- 180] deg
  3. *
  4. * @param lon lon to normalize
  5. * @param center center point
  6. * @return longitude into the range [center +/- 180] deg
  7. */
  8. static public double lonNormal(double lon, double center) {
  9. return center + Math.IEEEremainder(lon - center, 360.0);
  10. }

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

  1. @Override
  2. public double apply(double a) {
  3. return Math.IEEEremainder(a, b);
  4. }
  5. };

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

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

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

  1. /**
  2. * put longitude into the range [center +/- 180] deg
  3. *
  4. * @param lon lon to normalize
  5. * @param center center point
  6. * @return longitude into the range [center +/- 180] deg
  7. */
  8. static public double lonNormal(double lon, double center) {
  9. return center + Math.IEEEremainder(lon - center, 360.0);
  10. }

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

  1. @Override
  2. public double apply(double a) {
  3. return Math.IEEEremainder(a, b);
  4. }
  5. };

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

  1. double good0 = Math.IEEEremainder(1.0, -1.0);
  2. if (Double.isNaN(good0)) {
  3. assertTrue(
  4. assertEquals(
  5. "IEEEremainder of (1.0,-1.0):",
  6. (double) Math.IEEEremainder(1.0, -1.0),
  7. ((Double) IEEEremainderFunction.evaluate(null)).doubleValue(),
  8. 0.00001);
  9. double good1 = Math.IEEEremainder(-1.0, 2.0);
  10. if (Double.isNaN(good1)) {
  11. assertTrue(
  12. assertEquals(
  13. "IEEEremainder of (-1.0,2.0):",
  14. (double) Math.IEEEremainder(-1.0, 2.0),
  15. ((Double) IEEEremainderFunction.evaluate(null)).doubleValue(),
  16. 0.00001);
  17. double good2 = Math.IEEEremainder(2.0, -2.0);
  18. if (Double.isNaN(good2)) {
  19. assertTrue(
  20. assertEquals(
  21. "IEEEremainder of (2.0,-2.0):",
  22. (double) Math.IEEEremainder(2.0, -2.0),
  23. ((Double) IEEEremainderFunction.evaluate(null)).doubleValue(),
  24. 0.00001);

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

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

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

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

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

  1. /**
  2. * Starting from lon1, find
  3. * Find difference (lon1 - lon2) normalized so that maximum value is += 180.
  4. *
  5. * @param lon1 start
  6. * @param lon2 end
  7. * @return
  8. */
  9. static public double lonDiff(double lon1, double lon2) {
  10. return Math.IEEEremainder(lon1 - lon2, 720.0);
  11. }
  12. }

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

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

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

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

相关文章