Search results

There are no results.

std.endian.big.read_i32

Show source code
Hide source code
fn pub read_i32(from: ref ByteArray, at: Int) -> Int {
  if from.size - at < 4 { size_error(4) }

  ((from.to_pointer as Int + at as Pointer[UInt32]).0 as Int).swap_bytes >>> 32
}
fn pub static read_i32(from: ref ByteArray, at: Int) -> Int

Reads four bytes starting at at as a 32-bits signed integer.

Panics

This method panics if from doesn't contain at least 4 values starting at index at.

Examples

import std.endian.big

let bytes = ByteArray.filled(with: 0, times: 4)

big.write_i32(123456789, into: bytes, at: 0)
big.read_i32(from: bytes, at: 0) # => 123456789