gpt4 book ai didi

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

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

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

XMath.rool介绍

[英]Returns the next or previous representable number. If amount is equals to 0, then this method returns the value unchanged. Otherwise, The operation performed depends on the specified type:

  • If the type is Double, then this method is equivalent to invoking #previous(double) if amount is equals to -1, or invoking #next(double) if amount is equals to +1. If amount is smaller than -1 or greater than +1, then this method invokes #previous(double) or #next(double) in a loop for abs(amount) times.
  • If the type is Float, then this method is equivalent to invoking #previous(float) if amount is equals to -1, or invoking #next(float) if amount is equals to +1. If amount is smaller than -1 or greater than +1, then this method invokes #previous(float) or #next(float) in a loop for abs(amount) times.
  • If the type is an #isInteger, then invoking this method is equivalent to computing value + amount.
    [中]返回下一个或上一个可表示的数字。如果amount等于0,则此方法返回的值不变。否则,执行的操作取决于指定的类型:
    *如果类型是Double,那么这个方法相当于在amount等于-1时调用#previous(Double),或者在amount等于+1时调用#next(Double)。如果amount小于-1或大于+1,则此方法在循环中调用#previous(double)或#next(double)以获得abs(amount)次数。
    *如果类型为Float,则此方法相当于在amount等于-1时调用#previous(Float),或者在amount等于+1时调用#next(Float)。如果amount小于-1或大于+1,则此方法调用循环中的#previous(float)或#next(float)进行abs(amount)次数。
    *如果类型是#isInteger,那么调用此方法相当于计算value+amount。

代码示例

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

/**
 * Returns a {@code double} value for the specified number. If {@code direction}
 * is non-zero, then this method will returns the closest representable number of type
 * {@code type} before or after the double value.
 *
 * @param type      The range element class. {@code number} must be
 *                  an instance of this class (this will not be checked).
 * @param number    The number to transform to a {@code double} value.
 * @param direction -1 to return the previous representable number,
 *                  +1 to return the next representable number, or
 *                   0 to return the number with no change.
 */
private static double doubleValue(final Class<?>        type,
                 final Comparable number,
                 final int     direction)
{
  assert (direction >= -1) && (direction <= +1) : direction;
  return org.geotools.resources.XMath.rool(type, ((Number)number).doubleValue(), direction);
}

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

/**
 * Returns a {@code double} value for the specified number. If {@code direction}
 * is non-zero, then this method will returns the closest representable number of type
 * {@code type} before or after the double value.
 *
 * @param type      The range element class. {@code number} must be
 *                  an instance of this class (this will not be checked).
 * @param number    The number to transform to a {@code double} value.
 * @param direction -1 to return the previous representable number,
 *                  +1 to return the next representable number, or
 *                   0 to return the number with no change.
 */
private static double doubleValue(final Class        type,
                 final Comparable number,
                 final int     direction)
{
  assert (direction >= -1) && (direction <= +1) : direction;
  return XMath.rool(type, ((Number)number).doubleValue(), direction);
}

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

/**
 * Returns a {@code double} value for the specified number. If
 * {@code direction} is non-zero, then this method will returns the closest
 * representable number of type {@code type} before or after the double
 * value.
 * 
 * @param type
 *            The range element class. {@code number} must be an instance of
 *            this class (this will not be checked).
 * @param number
 *            The number to transform to a {@code double} value.
 * @param direction
 *            -1 to return the previous representable number, +1 to return
 *            the next representable number, or 0 to return the number with
 *            no change.
 */
static double doubleValue(final Class<? extends Number> type,
    final Number number, final int direction) {
  assert (direction >= -1) && (direction <= +1) : direction;
  return XMath.rool(type, number.doubleValue(), direction);
}

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

/**
 * Returns the {@linkplain #getMinimum() minimum value} with the specified inclusive or
 * exclusive state. If this range is unbounded, then {@link Double#NEGATIVE_INFINITY} is
 * returned.
 *
 * @param  inclusive {@code true} for the minimum value inclusive,
 *         or {@code false} for the minimum value exclusive.
 * @return The minimum value, inclusive or exclusive as requested.
 */
public double getMinimum(final boolean inclusive) {
  double value = getMinimum();
  if (inclusive != isMinIncluded()) {
    value = XMath.rool(getElementClass(), value, inclusive ? +1 : -1);
  }
  return value;
}

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

/**
 * Returns the {@linkplain #getMinimum() minimum value} with the specified inclusive or
 * exclusive state. If this range is unbounded, then {@link Double#NEGATIVE_INFINITY} is
 * returned.
 *
 * @param inclusive
 *            {@code true} for the minimum value inclusive, or {@code false}
 *            for the minimum value exclusive.
 * @return The minimum value, inclusive or exclusive as requested.
 */
public double getMinimum(final boolean inclusive) {
  double value = getMinimum();
  if (inclusive != isMinIncluded()) {
    value = XMath.rool(getElementClass(), value, inclusive ? +1 : -1);
  }
  return value;
}

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

/**
   * Returns the {@linkplain #getMaximum() maximum value} with the specified inclusive or
   * exclusive state. If this range is unbounded, then {@link Double#POSITIVE_INFINITY} is
   * returned.
   *
   * @param inclusive
   *            {@code true} for the maximum value inclusive, or {@code false}
   *            for the maximum value exclusive.
   * @return The maximum value, inclusive or exclusive as requested.
   */
  public double getMaximum(final boolean inclusive) {
    double value = getMaximum();
    if (inclusive != isMaxIncluded()) {
      value = XMath.rool(getElementClass(), value, inclusive ? -1 : +1);
    }
    return value;
  }
}

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

/**
   * Returns the {@linkplain #getMaximum() maximum value} with the specified inclusive or
   * exclusive state. If this range is unbounded, then {@link Double#POSITIVE_INFINITY} is
   * returned.
   *
   * @param  inclusive {@code true} for the maximum value inclusive,
   *         or {@code false} for the maximum value exclusive.
   * @return The maximum value, inclusive or exclusive as requested.
   */
  public double getMaximum(final boolean inclusive) {
    double value = getMaximum();
    if (inclusive != isMaxIncluded()) {
      value = XMath.rool(getElementClass(), value, inclusive ? -1 : +1);
    }
    return value;
  }
}

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