org.apache.sis.math.Vector.isUnsigned()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(68)

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

Vector.isUnsigned介绍

[英]Returns true if integer values shall be interpreted as unsigned values. This method may return true for data stored in byte[], short[], int[]or long[] arrays, but never for data stored in float[] and double[] arrays.

Unless otherwise noticed in Javadoc, users do not need to care about this information since Vector methods will perform automatically the operations needed for unsigned integers.
[中]如果整数值应解释为无符号值,则返回true。对于字节[]、短[]、int[]或长[]数组中存储的数据,此方法可能会返回true,但对于浮点[]和双[]数组中存储的数据,则不会返回true。
除非Javadoc中另有说明,否则用户不需要关心这些信息,因为向量方法将自动执行无符号整数所需的操作。

代码示例

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
 * Returns {@code true} only if both vectors are unsigned.
 */
@Override
public boolean isUnsigned() {
  return first.isUnsigned() && second.isUnsigned();
}

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

/**
 * Returns {@code true} only if both vectors are unsigned.
 */
@Override
public boolean isUnsigned() {
  return first.isUnsigned() && second.isUnsigned();
}

代码示例来源:origin: org.apache.sis.core/sis-utility

/** Delegates to the enclosing vector. */
@Override public boolean isUnsigned()               {return Vector.this.isUnsigned();}
@Override public boolean isNaN      (int index)     {return Vector.this.isNaN      (toBacking(index));}

代码示例来源:origin: org.apache.sis.core/sis-utility

@Override public boolean  isUnsigned()          {return Vector.this.isUnsigned();}
@Override public boolean  isNaN      (int i)    {return Vector.this.isNaN      (indices[i]);}

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

/** Delegates to the enclosing vector. */
@Override public boolean isUnsigned()               {return Vector.this.isUnsigned();}
@Override public boolean isNaN      (int index)     {return Vector.this.isNaN      (toBacking(index));}

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

@Override public final boolean isUnsigned()       {return base.isUnsigned();}
@Override public final int     size()             {return size;}

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

@Override public boolean  isUnsigned()          {return Vector.this.isUnsigned();}
@Override public boolean  isNaN      (int i)    {return Vector.this.isNaN      (indices[i]);}

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
 * Returns {@code a-b} as a signed value, throwing an exception if the result overflows a {@code long}.
 * The given values will be interpreted as unsigned values if this vector {@linkplain #isUnsigned() is unsigned}.
 *
 * @param  a  the first value, unsigned if {@link #isUnsigned()} return {@code true}.
 * @param  b  the value to subtract from {@code a}, unsigned if {@link #isUnsigned()} return {@code true}.
 * @return the difference, always signed.
 * @throws ArithmeticException if the difference is too large.
 *
 * @see Math#subtractExact(long, long)
 */
final long subtract(final long a, final long b) {
  final long inc = a - b;
  // The sign of the difference shall be the same than the sign of Long.compare(…).
  if ((((isUnsigned() ? JDK8.compareUnsigned(a, b) : Long.compare(a, b)) ^ inc) & Long.MIN_VALUE) != 0) {
    throw new ArithmeticException();
  }
  return inc;
}

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

/**
 * Returns {@code a-b} as a signed value, throwing an exception if the result overflows a {@code long}.
 * The given values will be interpreted as unsigned values if this vector {@linkplain #isUnsigned() is unsigned}.
 *
 * @param  a  the first value, unsigned if {@link #isUnsigned()} return {@code true}.
 * @param  b  the value to subtract from {@code a}, unsigned if {@link #isUnsigned()} return {@code true}.
 * @return the difference, always signed.
 * @throws ArithmeticException if the difference is too large.
 *
 * @see Math#subtractExact(long, long)
 */
final long subtract(final long a, final long b) {
  final long inc = a - b;
  // The sign of the difference shall be the same than the sign of Long.compare(…).
  if ((((isUnsigned() ? Long.compareUnsigned(a, b) : Long.compare(a, b)) ^ inc) & Long.MIN_VALUE) != 0) {
    throw new ArithmeticException();
  }
  return inc;
}

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

if (vec.isUnsigned()) {
  message = "Unsigned " + message;

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

return ArrayVector.newInstance(array, isUnsigned());

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

assertInstanceOf("vector.compress(0)", ArrayVector.class, compressed);
assertEquals("elementType", Byte.class, compressed.getElementType());
assertFalse("isUnsigned()", compressed.isUnsigned());
assertContentEquals(vec, compressed);
assertInstanceOf("vector.compress(0)", ArrayVector.class, compressed);
assertEquals("elementType", Byte.class, compressed.getElementType());
assertTrue("isUnsigned()", compressed.isUnsigned());
assertContentEquals(vec, compressed);
assertInstanceOf("vector.compress(0)", ArrayVector.class, compressed);
assertEquals("elementType", Short.class, compressed.getElementType());
assertFalse("isUnsigned()", compressed.isUnsigned());
assertContentEquals(vec, compressed);
assertInstanceOf("vector.compress(0)", ArrayVector.class, compressed);
assertEquals("elementType", Short.class, compressed.getElementType());
assertTrue("isUnsigned()", compressed.isUnsigned());
assertContentEquals(vec, compressed);
assertInstanceOf("vector.compress(0)", ArrayVector.class, compressed);
assertEquals("elementType", Byte.class, compressed.getElementType());
assertTrue("isUnsigned()", compressed.isUnsigned());
assertContentEquals(vec, compressed);
assertInstanceOf("vector.compress(0)", ArrayVector.class, compressed);
assertEquals("elementType", Float.class, compressed.getElementType());
assertFalse("isUnsigned()", compressed.isUnsigned());
assertContentEquals(vec, compressed);

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

if (vec.isUnsigned()) {
  message = "Unsigned " + message;
if (vec.isUnsigned()) {
  assertEquals(message, 2, range.getMinDouble(), STRICT);
  assertTrue  (message, range.getMaxDouble() > Byte.MAX_VALUE);

相关文章