pop!float example
ushort[] asPeek = [0x645A, 0x3ffb]; asPeek.pop!float.shouldEqual(1.964F); asPeek.length.shouldEqual(0); // float.sizeOf is 4bytes => 2 DM ushort[] input = [0x1eb8, 0xc19d]; input.length.shouldEqual(2); pop!float(input).shouldEqual(-19.64F); input.length.shouldEqual(0); input = [0x0, 0xBF00, 0x0, 0x3F00]; input.pop!float.shouldEqual(-0.5F); pop!float(input).shouldEqual(0.5F);
pop!double examples.
A double has size 8 bytes => 4DM
ushort[] input = [0x0, 0x0, 0x0, 0x3FE0]; input.length.shouldEqual(4); pop!double(input).shouldEqual(0.5); input.length.shouldEqual(0); input = [0x0, 0x0, 0x0, 0xBFE0]; pop!double(input).shouldEqual(-0.5); input = [0x00, 0x01, 0x02, 0x03]; input.length.shouldEqual(4); pop!int(input).shouldEqual(0x10000); input.length.shouldEqual(2); pop!int(input).shouldEqual(0x30002); input.length.shouldEqual(0);
pop!ushort and short examples
ushort[] input = [0xFFFF, 0xFFFF, 0xFFFB, 0xFFFB]; pop!ushort(input).shouldEqual(0xFFFF); pop!short(input).shouldEqual(-1); pop!ushort(input).shouldEqual(0xFFFB); pop!short(input).shouldEqual(-5);
Takes an input range of DM (ushort) and converts the first T.sizeof / 2 DM's to T. The array is consumed.