本文整理了Java中java.lang.Integer.signum()
方法的一些代码示例,展示了Integer.signum()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Integer.signum()
方法的具体详情如下:
包路径:java.lang.Integer
类名称:Integer
方法名:signum
[英]Returns the value of the signum function for the specified integer.
[中]返回指定整数的signum函数的值。
代码示例来源:origin: com.h2database/h2
@Override
public int getSignum() {
return Integer.signum(value);
}
代码示例来源:origin: com.h2database/h2
@Override
public int getSignum() {
return Integer.signum(ordinal);
}
代码示例来源:origin: com.h2database/h2
@Override
public int getSignum() {
return Integer.signum(value);
}
代码示例来源:origin: com.h2database/h2
@Override
public int getSignum() {
return Integer.signum(value);
}
代码示例来源:origin: org.hamcrest/hamcrest-all
@Override
public boolean matchesSafely(T actual) {
int compare = signum(actual.compareTo(expected));
return minCompare <= compare && compare <= maxCompare;
}
代码示例来源:origin: stackoverflow.com
Collections.sort(list, new Comparator<String>() {
public int compare(String a, String b) {
return Integer.signum(fixString(a) - fixString(b));
}
private int fixString(String in) {
return Integer.parseInt(in.substring(0, in.indexOf('_')));
}
});
代码示例来源:origin: google/guava
private static void runTestFuzzyCompare(int toleranceIndex) {
double tolerance = get(TOLERANCE_CANDIDATES, toleranceIndex);
for (double a : ALL_DOUBLE_CANDIDATES) {
for (double b : ALL_DOUBLE_CANDIDATES) {
int expected = DoubleMath.fuzzyEquals(a, b, tolerance) ? 0 : Double.compare(a, b);
int actual = DoubleMath.fuzzyCompare(a, b, tolerance);
assertEquals(Integer.signum(expected), Integer.signum(actual));
}
}
}
代码示例来源:origin: neo4j/neo4j
private <T> int compare( Comparator<T> comparator, T left, T right )
{
int cmp1 = comparator.compare( left, right );
int cmp2 = comparator.compare( right, left );
assertEquals( signum( cmp1 ), -signum( cmp2 ), format( "%s is not symmetric on %s and %s", comparator, left, right ) );
return cmp1;
}
}
代码示例来源:origin: neo4j/neo4j
private <T> int compare( Comparator<T> comparator, T left, T right )
{
int cmp1 = comparator.compare( left, right );
int cmp2 = comparator.compare( right, left );
assertEquals( signum( cmp1 ), -signum( cmp2 ), format( "%s is not symmetric on %s and %s", comparator, left, right ) );
return cmp1;
}
}
代码示例来源:origin: google/guava
public void testCompare() {
for (long a : UNSIGNED_INTS) {
for (long b : UNSIGNED_INTS) {
int cmpAsLongs = Longs.compare(a, b);
int cmpAsUInt = UnsignedInts.compare((int) a, (int) b);
assertEquals(Integer.signum(cmpAsLongs), Integer.signum(cmpAsUInt));
}
}
}
代码示例来源:origin: com.h2database/h2
@Override
public int compare(Object aObj, Object bObj) {
AutoDetectDataType aType = getType(aObj);
AutoDetectDataType bType = getType(bObj);
int typeDiff = aType.typeId - bType.typeId;
if (typeDiff == 0) {
return aType.compare(aObj, bObj);
}
return Integer.signum(typeDiff);
}
代码示例来源:origin: apache/hbase
/**
* Return true when the next encoded value in {@code src} uses Numeric
* encoding and is {@code NaN}, false otherwise.
*/
public static boolean isNumericNaN(PositionedByteRange src) {
return NAN == (-1 == Integer.signum(src.peek()) ? DESCENDING : ASCENDING).apply(src.peek());
}
代码示例来源:origin: apache/hbase
/**
* Return true when the next encoded value in {@code src} uses fixed-width
* Int32 encoding, false otherwise.
*/
public static boolean isFixedInt32(PositionedByteRange src) {
return FIXED_INT32 ==
(-1 == Integer.signum(src.peek()) ? DESCENDING : ASCENDING).apply(src.peek());
}
代码示例来源:origin: apache/hbase
/**
* Return true when the next encoded value in {@code src} uses BlobVar
* encoding, false otherwise.
*/
public static boolean isBlobVar(PositionedByteRange src) {
return BLOB_VAR ==
(-1 == Integer.signum(src.peek()) ? DESCENDING : ASCENDING).apply(src.peek());
}
代码示例来源:origin: apache/hbase
/**
* Return true when the next encoded value in {@code src} uses Numeric
* encoding, false otherwise. {@code NaN}, {@code +/-Inf} are valid Numeric
* values.
*/
public static boolean isNumeric(PositionedByteRange src) {
byte x = (-1 == Integer.signum(src.peek()) ? DESCENDING : ASCENDING).apply(src.peek());
return x >= NEG_INF && x <= NAN;
}
代码示例来源:origin: apache/hbase
/**
* Return true when the next encoded value in {@code src} uses Numeric
* encoding and is {@code Infinite}, false otherwise.
*/
public static boolean isNumericInfinite(PositionedByteRange src) {
byte x = (-1 == Integer.signum(src.peek()) ? DESCENDING : ASCENDING).apply(src.peek());
return NEG_INF == x || POS_INF == x;
}
代码示例来源:origin: apache/hbase
/**
* Return true when the next encoded value in {@code src} uses fixed-width
* Int8 encoding, false otherwise.
*/
public static boolean isFixedInt8(PositionedByteRange src) {
return FIXED_INT8 ==
(-1 == Integer.signum(src.peek()) ? DESCENDING : ASCENDING).apply(src.peek());
}
代码示例来源:origin: apache/hbase
/**
* Return true when the next encoded value in {@code src} uses BlobCopy
* encoding, false otherwise.
*/
public static boolean isBlobCopy(PositionedByteRange src) {
return BLOB_COPY ==
(-1 == Integer.signum(src.peek()) ? DESCENDING : ASCENDING).apply(src.peek());
}
代码示例来源:origin: com.h2database/h2
@Override
protected int compareSecure(Value v, CompareMode mode) {
if (type == Value.CLOB) {
return Integer.signum(getString().compareTo(v.getString()));
}
byte[] v2 = v.getBytesNoCopy();
return Bits.compareNotNullSigned(getBytesNoCopy(), v2);
}
代码示例来源:origin: redisson/redisson
/**
* {@inheritDoc}
*/
public int compareTo(ClassFileVersion other) {
return Integer.signum(getMajorVersion() == other.getMajorVersion()
? getMinorVersion() - other.getMinorVersion()
: getMajorVersion() - other.getMajorVersion());
}
内容来源于网络,如有侵权,请联系作者删除!