本文整理了Java中java.lang.Byte.toUnsignedLong()
方法的一些代码示例,展示了Byte.toUnsignedLong()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Byte.toUnsignedLong()
方法的具体详情如下:
包路径:java.lang.Byte
类名称:Byte
方法名:toUnsignedLong
暂无
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testGetUnsignedByte() throws Exception {
int bytesLen = 100;
byte[] bytes = TestUtils.randomByteArray(bytesLen);
Buffer b = Buffer.buffer(bytes);
for (int i = 0; i < bytesLen; i++) {
assertEquals(Byte.toUnsignedLong(bytes[i]), b.getUnsignedByte(i));
}
}
代码示例来源:origin: io.vertx/vertx-core
@Test
public void testGetUnsignedByte() throws Exception {
int bytesLen = 100;
byte[] bytes = TestUtils.randomByteArray(bytesLen);
Buffer b = Buffer.buffer(bytes);
for (int i = 0; i < bytesLen; i++) {
assertEquals(Byte.toUnsignedLong(bytes[i]), b.getUnsignedByte(i));
}
}
代码示例来源:origin: Baqend/Orestes-Bloomfilter
@Override
protected long decrement(int index) {
if(counters[index] == 0)
return 0;
return Byte.toUnsignedLong(--counters[index]);
}
代码示例来源:origin: Baqend/Orestes-Bloomfilter
@Override
protected long count(int index) {
return Byte.toUnsignedLong(counters[index]);
}
代码示例来源:origin: org.opendaylight.yangtools/yang-common
@Override
public final long longValue() {
return Byte.toUnsignedLong(value);
}
代码示例来源:origin: opendaylight/yangtools
@Override
public final long longValue() {
return Byte.toUnsignedLong(value);
}
代码示例来源:origin: Baqend/Orestes-Bloomfilter
@Override
protected long increment(int index) {
if(Byte.toUnsignedLong(counters[index]) == MAX) {
overflowHandler.run();
return MAX;
}
return Byte.toUnsignedLong(++counters[index]);
}
代码示例来源:origin: Baqend/Orestes-Bloomfilter
@Override
public Map<Integer, Long> getCountMap() {
Map<Integer, Long> result = new HashMap<>();
for (int i = 0; i < counters.length; i++) {
long count = Byte.toUnsignedLong(counters[i]);
if (count > 0) {
result.put(i, count);
}
}
return result;
}
代码示例来源:origin: net.dongliu/xhttp
private void verifyCrc(ByteBuffer in) {
long crcValue = 0;
for (int i = 0; i < 4; ++i) {
crcValue |= toUnsignedLong(in.get()) << i * 8;
}
long readCrc = crc.getValue();
if (crcValue != readCrc) {
throw new RuntimeException("CRC value missmatch. Expected: " + crcValue + ", Got: " + readCrc);
}
}
代码示例来源:origin: stackoverflow.com
byte b = (byte)255;
int c = Byte.toUnsignedInt(b); // 255
long asLong = Byte.toUnsignedLong(b); // 255
代码示例来源:origin: aicis/fresco
@Override
public long nextLong(long limit) {
if (limit < 1) {
throw new IllegalArgumentException("Limit must be strictly positive, but is: " + limit);
}
int bitSize = (Long.SIZE - Long.numberOfLeadingZeros(limit - 1));
byte[] bytes = getBytes(bitSize);
long result = Byte.toUnsignedLong(bytes[0]);
for (int i = 1; i < bytes.length; i++) {
result <<= 8;
result ^= Byte.toUnsignedLong(bytes[i]);
}
return result < limit ? result : nextLong(limit);
}
代码示例来源:origin: apache/sis
@Override public long longValue(int index) {return Byte.toUnsignedLong (super.byteValue(index));}
@Override public int intValue(int index) {return Byte.toUnsignedInt (super.byteValue(index));}
代码示例来源:origin: com.io7m.jcanephora/io7m-jcanephora-tests
Assert.assertEquals(512L * 512L * 2L, (long) data.capacity());
for (int index = 0; index < data.capacity(); ++index) {
Assert.assertEquals(0xffL, Byte.toUnsignedLong(data.get(index)));
代码示例来源:origin: ontio/ontology-java-sdk
public long readVarInt2(long max) throws IOException {
long fb = Byte.toUnsignedLong(readByte());
long value;
if (fb == ScriptOp.OP_PUSHDATA1.getByte()) {
value = Byte.toUnsignedLong(readByte());
} else if (fb == ScriptOp.OP_PUSHDATA2.getByte()) {
value = Short.toUnsignedLong(readShort());
} else if (fb == ScriptOp.OP_PUSHDATA4.getByte()) {
value = Integer.toUnsignedLong(readInt());
} else{
value = fb;
}
if (Long.compareUnsigned(value, max) > 0) {
throw new IOException(ErrorCode.ParamError);
}
return value;
}
public String readVarString() throws IOException {
代码示例来源:origin: ontio/ontology-java-sdk
public long readVarInt2(long max) throws IOException {
long fb = Byte.toUnsignedLong(readByte());
long value;
if (fb == ScriptOp.OP_PUSHDATA1.getByte()) {
value = Byte.toUnsignedLong(readByte());
} else if (fb == ScriptOp.OP_PUSHDATA2.getByte()) {
value = Short.toUnsignedLong(readShort());
} else if (fb == ScriptOp.OP_PUSHDATA4.getByte()) {
value = Integer.toUnsignedLong(readInt());
} else{
value = fb;
}
if (Long.compareUnsigned(value, max) > 0) {
throw new IOException(ErrorCode.ParamError);
}
return value;
}
public String readVarString() throws IOException {
代码示例来源:origin: com.io7m.jcanephora/io7m-jcanephora-tests
Assert.assertEquals(512L * 512L * 3L, (long) data.capacity());
for (int index = 0; index < data.capacity(); ++index) {
Assert.assertEquals(0xffL, Byte.toUnsignedLong(data.get(index)));
代码示例来源:origin: com.io7m.jcanephora/io7m-jcanephora-tests
Assert.assertEquals(512L * 512L, (long) data.capacity());
for (int index = 0; index < data.capacity(); ++index) {
Assert.assertEquals(0xffL, Byte.toUnsignedLong(data.get(index)));
代码示例来源:origin: neow3j/neow3j
public long readVarInt(long max) throws IOException {
long fb = Byte.toUnsignedLong(readByte());
long value;
if (fb == 0xFD) {
value = Short.toUnsignedLong(readShort());
} else if (fb == 0xFE) {
value = Integer.toUnsignedLong(readInt());
} else if (fb == 0xFF) {
value = readLong();
} else {
value = fb;
}
if (Long.compareUnsigned(value, max) > 0) {
throw new IOException();
}
return value;
}
代码示例来源:origin: ontio/ontology-java-sdk
public long readVarInt(long max) throws IOException {
long fb = Byte.toUnsignedLong(readByte());
long value;
if (fb == 0xFD) {
value = Short.toUnsignedLong(readShort());
} else if (fb == 0xFE) {
value = Integer.toUnsignedLong(readInt());
} else if (fb == 0xFF) {
value = readLong();
} else {
value = fb;
}
if (Long.compareUnsigned(value, max) > 0) {
throw new IOException(ErrorCode.ParamError);
}
return value;
}
public long readVarInt2(long max) throws IOException {
代码示例来源:origin: ontio/ontology-java-sdk
public long readVarInt(long max) throws IOException {
long fb = Byte.toUnsignedLong(readByte());
long value;
if (fb == 0xFD) {
value = Short.toUnsignedLong(readShort());
} else if (fb == 0xFE) {
value = Integer.toUnsignedLong(readInt());
} else if (fb == 0xFF) {
value = readLong();
} else {
value = fb;
}
if (Long.compareUnsigned(value, max) > 0) {
throw new IOException(ErrorCode.ParamError);
}
return value;
}
public long readVarInt2(long max) throws IOException {
内容来源于网络,如有侵权,请联系作者删除!