gpt4 book ai didi

org.geotools.resources.XMath.next()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-23 03:13:05 25 4
gpt4 key购买 nike

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

XMath.next介绍

[英]Finds the least double greater than f. If NaN, returns same value.
[中]查找至少大于f的两倍。如果为NaN,则返回相同的值。

代码示例

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Finds the least float greater than <var>f</var>.
 * If {@code NaN}, returns same value.
 *
 * @todo Remove this method when we will be allowed to use Java 6.
 */
public static float next(final float f) {
  return next(f, true);
}

代码示例来源:origin: org.geotools/gt2-metadata

/**
 * Finds the least float greater than <var>f</var>.
 * If {@code NaN}, returns same value.
 *
 * @todo Remove this method when we will be allowed to use J2SE 1.5.
 */
public static float next(final float f) {
  return next(f, true);
}

代码示例来源:origin: org.geotools/gt2-metadata

/**
 * Finds the greatest float less than <var>f</var>.
 * If {@code NaN}, returns same value.
 *
 * @todo Remove this method when we will be allowed to use J2SE 1.5.
 */
public static float previous(final float f) {
  return next(f, false);
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Finds the greatest float less than <var>f</var>.
 * If {@code NaN}, returns same value.
 *
 * @todo Remove this method when we will be allowed to use Java 6.
 */
public static float previous(final float f) {
  return next(f, false);
}

代码示例来源:origin: org.geotools/gt2-metadata

/**
 * Round the specified value, providing that the difference between the original value and
 * the rounded value is not greater than the specified amount of floating point units. This
 * method can be used for hiding floating point error likes 2.9999999996.
 *
 * @param  value The value to round.
 * @param  flu The amount of floating point units.
 * @return The rounded value, of {@code value} if it was not close enough to an integer.
 */
public static double round(final double value, int flu) {
  final double target = Math.rint(value);
  if (value != target) {
    final boolean pos = (value < target);
    double candidate = value;
    while (--flu >= 0) {
      candidate = pos ? next(candidate) : previous(candidate);
      if (candidate == target) {
        return target;
      }
    }
  }
  return value;
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Rounds the specified value, providing that the difference between the original value and
 * the rounded value is not greater than the specified amount of floating point units. This
 * method can be used for hiding floating point error likes 2.9999999996.
 *
 * @param  value The value to round.
 * @param  maxULP The maximal change allowed in ULPs (Unit in the Last Place).
 * @return The rounded value, of {@code value} if it was not close enough to an integer.
 */
public static double roundIfAlmostInteger(final double value, int maxULP) {
  final double target = Math.rint(value);
  if (value != target) {
    final boolean pos = (value < target);
    double candidate = value;
    while (--maxULP >= 0) {
      candidate = pos ? next(candidate) : previous(candidate);
      if (candidate == target) {
        return target;
      }
    }
  }
  return value;
}

代码示例来源:origin: org.geotools/gt-metadata

} else if (amount!=0) {
  do {
    value = next(value);
  } while (--amount != 0);
} else if (amount!=0) {
  do {
    vf = next(vf);
  } while (--amount != 0);

代码示例来源:origin: org.geotools/gt2-metadata

} else if (amount!=0) {
  do {
    value = next(value);
  } while (--amount != 0);
} else if (amount!=0) {
  do {
    vf = next(vf);
  } while (--amount != 0);

代码示例来源:origin: org.geotools/gt2-metadata

/**
 * Try to remove at least {@code n} fraction digits in the string representation of
 * the specified value. This method try small changes to {@code value}, by adding or
 * substracting a maximum of 4 ulps. If there is no small change that remove at least
 * {@code n} fraction digits, then the value is returned unchanged. This method is
 * used for hiding rounding errors, like in conversions from radians to degrees.
 *
 * <P>Example: {@code XMath.fixRoundingError(-61.500000000000014, 12)} returns
 * {@code -61.5}.
 *
 * @param  value The value to fix.
 * @param  n The minimum amount of fraction digits.
 * @return The fixed value, or the unchanged {@code value} if there is no small change
 *         that remove at least {@code n} fraction digits.
 */
public static double fixRoundingError(final double value, int n) {
  double lower = value;
  double upper = value;
  n = countFractionDigits(value) - n;
  if (n > 0) {
    for (int i=0; i<4; i++) {
      if (countFractionDigits(lower = previous(lower)) <= n) return lower;
      if (countFractionDigits(upper = next    (upper)) <= n) return upper;
    }
  }
  return value;
}

代码示例来源:origin: org.geotools/gt-metadata

/**
 * Tries to remove at least {@code n} fraction digits in the decimal representation of
 * the specified value. This method tries small changes to {@code value}, by adding or
 * substracting up to {@code maxULP} (Unit in the Last Place). If there is no small
 * change that remove at least {@code n} fraction digits, then the value is returned
 * unchanged. This method is used for hiding rounding errors, like in conversions from
 * radians to degrees.
 * <P>
 * Example:
 * {@code XMath.trimLastDecimalDigits(-61.500000000000014, 12, 4)} returns {@code -61.5}.
 *
 * @param  value The value to fix.
 * @param  maxULP The maximal change allowed in ULPs (Unit in the Last Place).
 *         A typical value is 4.
 * @param  n The minimum amount of fraction digits.
 * @return The trimmed value, or the unchanged {@code value} if there is no small change
 *         that remove at least {@code n} fraction digits.
 */
public static double trimDecimalFractionDigits(final double value, final int maxULP, int n) {
  double lower = value;
  double upper = value;
  n = countDecimalFractionDigits(value) - n;
  if (n > 0) {
    for (int i=0; i<maxULP; i++) {
      if (countDecimalFractionDigits(lower = previous(lower)) <= n) return lower;
      if (countDecimalFractionDigits(upper = next    (upper)) <= n) return upper;
    }
  }
  return value;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com