peek

Takes an array of word (ushort) and converts the first T.sizeof / 2 word to T starting from index index.

The array is not consumed.

  1. T peek(ushort[] words)
  2. T peek(ushort[] words, size_t index)
    T
    peek
    (
    T
    )
    (
    ushort[] words
    ,
    size_t index
    )

Parameters

T

The integral type to convert the first T.sizeof / 2 word to.

words
Type: ushort[]

The array of word to convert

index
Type: size_t

The index to start reading from (instead of starting at the front).

Examples

1 assert([0x645A, 0x3ffb].peek!float(0) == 1.964F);
2 assert([0, 0, 0x645A, 0x3ffb].peek!float(2) == 1.964F);
3 assert([0, 0, 0x645A, 0x3ffb].peek!float(0) == 0);
4 assert([0x80, 0, 0].peek!ushort(0) == 128);
5 assert([0xFFFF].peek!short(0) == -1);
6 assert([0xFFFF].peek!ushort(0) == 65_535);
7 assert([0xFFF7].peek!ushort(0) == 65_527);
8 assert([0xFFF7].peek!short(0) == -9);
9 assert([0xFFFB].peek!short(0) == -5);
10 assert([0xFFFB].peek!ushort(0) == 65_531);
11 assert([0x8000].peek!short(0) == -32_768);

Meta