write

Writes numeric type *T* into a output range of *ushort*.

void
write
(
T
R
)
(
ref R output
,
T n
)
if (
isOutputRange!(R, ushort)
)

Parameters

n T

The numeric type to write into output range

output R

The output range of DM to convert

Examples

ushort[] arr;
auto app = appender(arr);
write!float(app, 1.0f);


auto app = appender!(const(ushort)[]);
app.write!ushort(5);
app.data.shouldEqual([5]);

Write float and double

ushort[] arr;
auto app = appender(arr);
write!float(app, 1.0f);

app.write!double(2.0);

ushort[] expected = [0, 0x3f80, 0, 0, 0, 0x4000];
app.data.shouldEqual(expected);

Write ushort and int

import std.array : appender;

auto app = appender!(const(ushort)[]);
app.write!ushort(5);
app.data.shouldEqual([5]);

app.write!float(1.964F);
app.data.shouldEqual([5, 0x645A, 0x3ffb]);

app.write!uint(0x1720_8034);
app.data.shouldEqual([5, 0x645A, 0x3ffb, 0x8034, 0x1720]);

Meta