org.apache.sis.util.Numbers.isFloat()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(150)

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

Numbers.isFloat介绍

[英]true for floating point number.
[中]浮点数为true。

代码示例

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

/**
 * Tests {@link Numbers#isFloat(Class)}.
 */
@Test
public void testIsFloat() {
  assertFalse(isFloat(Byte     .TYPE));
  assertFalse(isFloat(Short    .TYPE));
  assertFalse(isFloat(Integer  .TYPE));
  assertFalse(isFloat(Long     .TYPE));
  assertTrue (isFloat(Float    .TYPE));
  assertTrue (isFloat(Double   .TYPE));
  assertFalse(isFloat(Byte     .class));
  assertFalse(isFloat(Short    .class));
  assertFalse(isFloat(Integer  .class));
  assertFalse(isFloat(Long     .class));
  assertTrue (isFloat(Float    .class));
  assertTrue (isFloat(Double   .class));
  assertFalse(isFloat(String   .class));
  assertFalse(isFloat(Character.class));
}

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

/**
 * Sets the values in this variable. The values are normally read from the netCDF file by the {@link #read()} method,
 * but this {@code setValues(Object)} method may also be invoked if we want to overwrite those values.
 *
 * @param  array  the values as an array of primitive type (for example {@code float[]}.
 */
final void setValues(final Object array) {
  Vector data = createDecimalVector(array, dataType.isUnsigned);
  /*
   * This method is usually invoked with vector of increasing or decreasing values.  Set a tolerance threshold to the
   * precision of gratest (in magnitude) number, provided that this precision is not larger than increment. If values
   * are not sorted in increasing or decreasing order, the tolerance computed below will be smaller than it could be.
   * This is okay it will cause more conservative compression (i.e. it does not increase the risk of data loss).
   */
  double tolerance = 0;
  if (Numbers.isFloat(data.getElementType())) {
    final int n = data.size() - 1;
    if (n >= 0) {
      double first = data.doubleValue(0);
      double last  = data.doubleValue(n);
      double inc   = Math.abs((last - first) / n);
      if (!Double.isNaN(inc)) {
        double ulp = Math.ulp(Math.max(Math.abs(first), Math.abs(last)));
        tolerance = Math.min(inc, ulp);
      }
    }
  }
  values = data.compress(tolerance);
  values = SHARED_VECTORS.unique(values);
}

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

if (format instanceof DecimalFormat && Numbers.isFloat(value.getClass())) {
  final double number = ((Number) value).doubleValue();
  if (number != (int) number) {   // Cast to 'int' instead of 'long' as a way to limit to about 2E9.

相关文章