pop

Takes an input range of DM (ushort) and converts the first T.sizeof / 2 DM's to T. The array is consumed.

T
pop
(
T
R
)
(
ref R input
)
if (
(isInputRange!R) &&
is(ElementType!R : const ushort)
)

Parameters

T

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

input
Type: R

The input range of DM to convert

Examples

pop!float example

1 ushort[] asPeek = [0x645A, 0x3ffb];
2 asPeek.pop!float.shouldEqual(1.964F);
3 asPeek.length.shouldEqual(0);
4 
5 // float.sizeOf is 4bytes => 2 DM
6 ushort[] input = [0x1eb8, 0xc19d];
7 input.length.shouldEqual(2);
8 pop!float(input).shouldEqual(-19.64F);
9 input.length.shouldEqual(0);
10 
11 input = [0x0, 0xBF00, 0x0, 0x3F00];
12 input.pop!float.shouldEqual(-0.5F);
13 pop!float(input).shouldEqual(0.5F);

pop!double examples.

A double has size 8 bytes => 4DM

1 ushort[] input = [0x0, 0x0, 0x0, 0x3FE0];
2 input.length.shouldEqual(4);
3 
4 pop!double(input).shouldEqual(0.5);
5 input.length.shouldEqual(0);
6 
7 input = [0x0, 0x0, 0x0, 0xBFE0];
8 pop!double(input).shouldEqual(-0.5);
9 
10 input = [0x00, 0x01, 0x02, 0x03];
11 input.length.shouldEqual(4);
12 pop!int(input).shouldEqual(0x10000);
13 input.length.shouldEqual(2);
14 pop!int(input).shouldEqual(0x30002);
15 input.length.shouldEqual(0);

pop!ushort and short examples

1 ushort[] input = [0xFFFF, 0xFFFF, 0xFFFB, 0xFFFB];
2 pop!ushort(input).shouldEqual(0xFFFF);
3 pop!short(input).shouldEqual(-1);
4 pop!ushort(input).shouldEqual(0xFFFB);
5 pop!short(input).shouldEqual(-5);

Meta