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

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

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

Numbers.primitiveBitCount介绍

[英]Returns the number of bits used by primitive of the specified type. The given type must be a primitive type or its wrapper class.
[中]返回指定类型的基元使用的位数。给定的类型必须是基元类型或其包装类。

代码示例

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

/**
 * Returns an estimation of the number of bits used by each value in this vector.
 * This is an estimation only and should be used only as a hint.
 */
private int getBitCount() {
  try {
    return Numbers.primitiveBitCount(getElementType());
  } catch (IllegalArgumentException e) {
    return Integer.SIZE;                    // Assume references compressed on 32 bits.
  }
}

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

/**
 * Tests {@link Numbers#primitiveBitCount(Class)}.
 */
@Test
public void testPrimitiveBitCount() {
  assertEquals(Byte   .SIZE, primitiveBitCount(Byte   .class));
  assertEquals(Short  .SIZE, primitiveBitCount(Short  .class));
  assertEquals(Integer.SIZE, primitiveBitCount(Integer.class));
  assertEquals(Long.   SIZE, primitiveBitCount(Long   .class));
  assertEquals(Float  .SIZE, primitiveBitCount(Float  .class));
  assertEquals(Double .SIZE, primitiveBitCount(Double .class));
}

相关文章