java.lang.Integer.signum()方法的使用及代码示例

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

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

Integer.signum介绍

[英]Returns the value of the signum function for the specified integer.
[中]返回指定整数的signum函数的值。

代码示例

代码示例来源:origin: com.h2database/h2

  1. @Override
  2. public int getSignum() {
  3. return Integer.signum(value);
  4. }

代码示例来源:origin: com.h2database/h2

  1. @Override
  2. public int getSignum() {
  3. return Integer.signum(ordinal);
  4. }

代码示例来源:origin: com.h2database/h2

  1. @Override
  2. public int getSignum() {
  3. return Integer.signum(value);
  4. }

代码示例来源:origin: com.h2database/h2

  1. @Override
  2. public int getSignum() {
  3. return Integer.signum(value);
  4. }

代码示例来源:origin: org.hamcrest/hamcrest-all

  1. @Override
  2. public boolean matchesSafely(T actual) {
  3. int compare = signum(actual.compareTo(expected));
  4. return minCompare <= compare && compare <= maxCompare;
  5. }

代码示例来源:origin: stackoverflow.com

  1. Collections.sort(list, new Comparator<String>() {
  2. public int compare(String a, String b) {
  3. return Integer.signum(fixString(a) - fixString(b));
  4. }
  5. private int fixString(String in) {
  6. return Integer.parseInt(in.substring(0, in.indexOf('_')));
  7. }
  8. });

代码示例来源:origin: google/guava

  1. private static void runTestFuzzyCompare(int toleranceIndex) {
  2. double tolerance = get(TOLERANCE_CANDIDATES, toleranceIndex);
  3. for (double a : ALL_DOUBLE_CANDIDATES) {
  4. for (double b : ALL_DOUBLE_CANDIDATES) {
  5. int expected = DoubleMath.fuzzyEquals(a, b, tolerance) ? 0 : Double.compare(a, b);
  6. int actual = DoubleMath.fuzzyCompare(a, b, tolerance);
  7. assertEquals(Integer.signum(expected), Integer.signum(actual));
  8. }
  9. }
  10. }

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

  1. private <T> int compare( Comparator<T> comparator, T left, T right )
  2. {
  3. int cmp1 = comparator.compare( left, right );
  4. int cmp2 = comparator.compare( right, left );
  5. assertEquals( signum( cmp1 ), -signum( cmp2 ), format( "%s is not symmetric on %s and %s", comparator, left, right ) );
  6. return cmp1;
  7. }
  8. }

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

  1. private <T> int compare( Comparator<T> comparator, T left, T right )
  2. {
  3. int cmp1 = comparator.compare( left, right );
  4. int cmp2 = comparator.compare( right, left );
  5. assertEquals( signum( cmp1 ), -signum( cmp2 ), format( "%s is not symmetric on %s and %s", comparator, left, right ) );
  6. return cmp1;
  7. }
  8. }

代码示例来源:origin: google/guava

  1. public void testCompare() {
  2. for (long a : UNSIGNED_INTS) {
  3. for (long b : UNSIGNED_INTS) {
  4. int cmpAsLongs = Longs.compare(a, b);
  5. int cmpAsUInt = UnsignedInts.compare((int) a, (int) b);
  6. assertEquals(Integer.signum(cmpAsLongs), Integer.signum(cmpAsUInt));
  7. }
  8. }
  9. }

代码示例来源:origin: com.h2database/h2

  1. @Override
  2. public int compare(Object aObj, Object bObj) {
  3. AutoDetectDataType aType = getType(aObj);
  4. AutoDetectDataType bType = getType(bObj);
  5. int typeDiff = aType.typeId - bType.typeId;
  6. if (typeDiff == 0) {
  7. return aType.compare(aObj, bObj);
  8. }
  9. return Integer.signum(typeDiff);
  10. }

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

  1. /**
  2. * Return true when the next encoded value in {@code src} uses Numeric
  3. * encoding and is {@code NaN}, false otherwise.
  4. */
  5. public static boolean isNumericNaN(PositionedByteRange src) {
  6. return NAN == (-1 == Integer.signum(src.peek()) ? DESCENDING : ASCENDING).apply(src.peek());
  7. }

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

  1. /**
  2. * Return true when the next encoded value in {@code src} uses fixed-width
  3. * Int32 encoding, false otherwise.
  4. */
  5. public static boolean isFixedInt32(PositionedByteRange src) {
  6. return FIXED_INT32 ==
  7. (-1 == Integer.signum(src.peek()) ? DESCENDING : ASCENDING).apply(src.peek());
  8. }

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

  1. /**
  2. * Return true when the next encoded value in {@code src} uses BlobVar
  3. * encoding, false otherwise.
  4. */
  5. public static boolean isBlobVar(PositionedByteRange src) {
  6. return BLOB_VAR ==
  7. (-1 == Integer.signum(src.peek()) ? DESCENDING : ASCENDING).apply(src.peek());
  8. }

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

  1. /**
  2. * Return true when the next encoded value in {@code src} uses Numeric
  3. * encoding, false otherwise. {@code NaN}, {@code +/-Inf} are valid Numeric
  4. * values.
  5. */
  6. public static boolean isNumeric(PositionedByteRange src) {
  7. byte x = (-1 == Integer.signum(src.peek()) ? DESCENDING : ASCENDING).apply(src.peek());
  8. return x >= NEG_INF && x <= NAN;
  9. }

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

  1. /**
  2. * Return true when the next encoded value in {@code src} uses Numeric
  3. * encoding and is {@code Infinite}, false otherwise.
  4. */
  5. public static boolean isNumericInfinite(PositionedByteRange src) {
  6. byte x = (-1 == Integer.signum(src.peek()) ? DESCENDING : ASCENDING).apply(src.peek());
  7. return NEG_INF == x || POS_INF == x;
  8. }

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

  1. /**
  2. * Return true when the next encoded value in {@code src} uses fixed-width
  3. * Int8 encoding, false otherwise.
  4. */
  5. public static boolean isFixedInt8(PositionedByteRange src) {
  6. return FIXED_INT8 ==
  7. (-1 == Integer.signum(src.peek()) ? DESCENDING : ASCENDING).apply(src.peek());
  8. }

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

  1. /**
  2. * Return true when the next encoded value in {@code src} uses BlobCopy
  3. * encoding, false otherwise.
  4. */
  5. public static boolean isBlobCopy(PositionedByteRange src) {
  6. return BLOB_COPY ==
  7. (-1 == Integer.signum(src.peek()) ? DESCENDING : ASCENDING).apply(src.peek());
  8. }

代码示例来源:origin: com.h2database/h2

  1. @Override
  2. protected int compareSecure(Value v, CompareMode mode) {
  3. if (type == Value.CLOB) {
  4. return Integer.signum(getString().compareTo(v.getString()));
  5. }
  6. byte[] v2 = v.getBytesNoCopy();
  7. return Bits.compareNotNullSigned(getBytesNoCopy(), v2);
  8. }

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

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public int compareTo(ClassFileVersion other) {
  5. return Integer.signum(getMajorVersion() == other.getMajorVersion()
  6. ? getMinorVersion() - other.getMinorVersion()
  7. : getMajorVersion() - other.getMajorVersion());
  8. }

相关文章