Fix int52
This commit is contained in:
parent
1512bf490a
commit
2dfd2cc86e
@ -1,10 +1,24 @@
|
||||
package it.cavallium.data.generator.nativedata;
|
||||
|
||||
import java.lang.annotation.Native;
|
||||
import java.util.Objects;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Int52 extends Number implements Comparable<Int52> {
|
||||
|
||||
/**
|
||||
* The number of bits used to represent a {@code Int52} value in two's
|
||||
* complement binary form.
|
||||
*/
|
||||
@Native
|
||||
public static final int SIZE = 52;
|
||||
|
||||
/**
|
||||
* The number of bytes used to represent a {@code Int52} value in two's
|
||||
* complement binary form.
|
||||
*/
|
||||
public static final int BYTES = 7;
|
||||
|
||||
private final long value;
|
||||
|
||||
private Int52(long value) {
|
||||
|
@ -35,7 +35,7 @@ public class Int52Serializer implements DataSerializer<Int52> {
|
||||
}
|
||||
|
||||
public static long fromByteArray(byte[] bytes) {
|
||||
if (bytes.length != 8) {
|
||||
if (bytes.length != 7) {
|
||||
throw new IllegalArgumentException("Size must be 7, got " + bytes.length + " instead");
|
||||
}
|
||||
return fromBytes((byte) (bytes[0] & 0b00001111), bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user