std.endian.little.read_i64
Show source codeHide source code
fn pub read_i64(from: ref ByteArray, at: Int) -> Int {
if from.size - at < 8 { panic('the ByteArray must contain at least 8 bytes') }
(from.to_pointer as Int + at as Pointer[UInt64]).0 as Int
}
fn pub static read_i64(from: ref ByteArray, at: Int) -> Int
Reads eight bytes starting at at
as a 64-bits signed integer.
Panics
This method panics if from
doesn't contain at least 8 values starting at
index at
.
Examples
import std.endian.little
let bytes = ByteArray.filled(with: 0, times: 8)
little.write_i64(123456789, into: bytes, at: 0)
little.read_i64(from: bytes, at: 0) # => 123456789