use of elemental2.core.Int8Array in project console by hal.
the class DataInput method readDouble.
double readDouble() {
byte[] doubleBytes = new byte[8];
readFully(doubleBytes);
ArrayBuffer buffer = new ArrayBuffer(8);
Int8Array array = new Int8Array(buffer);
DataView view = new DataView(buffer);
for (int i = 0; i < doubleBytes.length; i++) {
array.setAt(i, (double) doubleBytes[i]);
}
return view.getFloat64(0);
}
use of elemental2.core.Int8Array in project console by hal.
the class DataOutput method writeDouble.
void writeDouble(double v) {
ArrayBuffer buffer = new ArrayBuffer(8);
Int8Array array = new Int8Array(buffer);
DataView view = new DataView(buffer);
view.setFloat64(0, v);
for (int i = 0; i < array.getLength(); i++) {
bytes.push(array.getAt(i).byteValue());
}
}
Aggregations