public static void serialize(SerializationStreamWriter writer, UnsignedLong instance) throws SerializationException { writer.writeLong(instance.longValue()); } }
@Override public String getValue() { return Long.toString(value.longValue()); } }
public DoubleTypeNode(BinaryReader binaryReader, ChunkHeader chunkHeader, BxmlNode parent, int length) throws IOException { super(binaryReader, chunkHeader, parent, length); UnsignedLong unsignedLong = binaryReader.readQWord(); value = Double.longBitsToDouble(unsignedLong.longValue()); }
/** * Reads a timestamp that is the number of hundreds of nanoseconds since Jan 1 1601 * (see http://integriography.wordpress.com/2010/01/16/using-phython-to-parse-and-present-windows-64-bit-timestamps/) * * @return the date corresponding to the timestamp */ public Date readFileTime() { UnsignedLong hundredsOfNanosecondsSinceJan11601 = readQWord(); long millisecondsSinceJan11601 = hundredsOfNanosecondsSinceJan11601.dividedBy(UnsignedLong.valueOf(10000)).longValue(); long millisecondsSinceEpoch = millisecondsSinceJan11601 - EPOCH_OFFSET; return new Date(millisecondsSinceEpoch); }
public void testAsUnsignedAndLongValueAreInverses() { for (long value : TEST_LONGS) { assertEquals( UnsignedLongs.toString(value), value, UnsignedLong.fromLongBits(value).longValue()); } }
public void testPlus() { for (long a : TEST_LONGS) { for (long b : TEST_LONGS) { UnsignedLong aUnsigned = UnsignedLong.fromLongBits(a); UnsignedLong bUnsigned = UnsignedLong.fromLongBits(b); long expected = aUnsigned.bigIntegerValue().add(bUnsigned.bigIntegerValue()).longValue(); UnsignedLong unsignedSum = aUnsigned.plus(bUnsigned); assertEquals(expected, unsignedSum.longValue()); } } }
public void testMinus() { for (long a : TEST_LONGS) { for (long b : TEST_LONGS) { UnsignedLong aUnsigned = UnsignedLong.fromLongBits(a); UnsignedLong bUnsigned = UnsignedLong.fromLongBits(b); long expected = aUnsigned.bigIntegerValue().subtract(bUnsigned.bigIntegerValue()).longValue(); UnsignedLong unsignedSub = aUnsigned.minus(bUnsigned); assertEquals(expected, unsignedSub.longValue()); } } }
public void testTimes() { for (long a : TEST_LONGS) { for (long b : TEST_LONGS) { UnsignedLong aUnsigned = UnsignedLong.fromLongBits(a); UnsignedLong bUnsigned = UnsignedLong.fromLongBits(b); long expected = aUnsigned.bigIntegerValue().multiply(bUnsigned.bigIntegerValue()).longValue(); UnsignedLong unsignedMul = aUnsigned.times(bUnsigned); assertEquals(expected, unsignedMul.longValue()); } } }
public void testDividedBy() { for (long a : TEST_LONGS) { for (long b : TEST_LONGS) { if (b != 0) { UnsignedLong aUnsigned = UnsignedLong.fromLongBits(a); UnsignedLong bUnsigned = UnsignedLong.fromLongBits(b); long expected = aUnsigned.bigIntegerValue().divide(bUnsigned.bigIntegerValue()).longValue(); UnsignedLong unsignedDiv = aUnsigned.dividedBy(bUnsigned); assertEquals(expected, unsignedDiv.longValue()); } } } }
public void testValueOfLong() { for (long value : TEST_LONGS) { boolean expectSuccess = value >= 0; try { assertEquals(value, UnsignedLong.valueOf(value).longValue()); assertTrue(expectSuccess); } catch (IllegalArgumentException e) { assertFalse(expectSuccess); } } }
public void testMod() { for (long a : TEST_LONGS) { for (long b : TEST_LONGS) { if (b != 0) { UnsignedLong aUnsigned = UnsignedLong.fromLongBits(a); UnsignedLong bUnsigned = UnsignedLong.fromLongBits(b); long expected = aUnsigned.bigIntegerValue().remainder(bUnsigned.bigIntegerValue()).longValue(); UnsignedLong unsignedRem = aUnsigned.mod(bUnsigned); assertEquals(expected, unsignedRem.longValue()); } } } }
public static void serialize(SerializationStreamWriter writer, UnsignedLong instance) throws SerializationException { writer.writeLong(instance.longValue()); } }
@Override public Value<?> parse(final Session.Resolver resolver, final ByteBuffer buffer) { return new FloatValue(name, semantics, Double.longBitsToDouble(uint(buffer, buffer.remaining()).longValue())); }
private long fnvBits(CharSequence chars) { final int length = chars.length(); long hash = FNV64_OFFSET_BASIS.longValue(); for (int i = 0; i < length; i++) { char c = chars.charAt(i); byte b1 = (byte) (c >> 8); byte b2 = (byte) c; hash = update(hash, b1); hash = update(hash, b2); } return hash; }
public void writeBson(final BsonWriter bsonWriter) { bsonWriter.writeStartDocument(); bsonWriter.writeInt64("capacity", this.capacity.longValue()); bsonWriter.writeInt64("allocation", this.allocation.longValue()); bsonWriter.writeInt64("available", this.available.longValue()); bsonWriter.writeInt64("rd_req", this.rd_req); bsonWriter.writeInt64("rd_bytes", this.rd_bytes.longValue()); bsonWriter.writeInt64("wr_req", this.wr_req); bsonWriter.writeInt64("wr_bytes", this.wr_bytes.longValue()); bsonWriter.writeInt64("errs", this.errs); bsonWriter.writeEndDocument(); }
@Override public void accept(final UnsignedValue value) { // TODO: Mark this as unsigned? this.writer.writeInt64(value.getName(), value.getValue().longValue()); }
public void writeBson(final BsonWriter bsonWriter) { bsonWriter.writeStartDocument(); bsonWriter.writeInt64("vlan_id", this.vlan_id); bsonWriter.writeInt64("octets", this.octets.longValue()); bsonWriter.writeInt64("ucastPkts", this.ucastPkts); bsonWriter.writeInt64("multicastPkts", this.multicastPkts); bsonWriter.writeInt64("broadcastPkts", this.broadcastPkts); bsonWriter.writeInt64("discards", this.discards); bsonWriter.writeEndDocument(); }
@Test void initiateValidatorExitNotActive() { BeaconState state = newState(); int validator_index = 0; state.initiate_validator_exit(validator_index); assertThat(state.getValidator_registry().get(validator_index).getStatus().longValue()) .isEqualTo(ACTIVATION); }
@Test void exitValidatorPrevStatusExitedWithPenaltyNewStatusExitedWithoutPenalty() { BeaconState state = newState(); int validator_index = 4; state.exit_validator(state, validator_index, EXITED_WITHOUT_PENALTY); assertThat(state.getValidator_registry().get(validator_index).getStatus().longValue()) .isEqualTo(EXITED_WITH_PENALTY); }