Function: writeTemplate16()
ts
function writeTemplate16(cursor, value): void;Defined in: cursor/writeTemplate16.ts:18
Writes a fixed-point value of 2 bytes (8.8): 1 byte for the integer part and 1 byte for the fraction. The field is unsigned. The function rounds the value to the nearest value of the field.
Parameters
cursor
The cursor to write to. The function moves the cursor past the field.
value
number
The value to write.
Returns
void
Throws
RangeError if the rounded value does not fit the field. The error is the error of writeUint16, with the value in units of the field. The cursor does not move.
Example
ts
const cursor = createIsoBoxWriteCursor()
writeUint8(cursor, 1) // version
writeUint24(cursor, 0x000201) // flags
writeUint32(cursor, 7)
const bytes = cursor.bytes.subarray(0, cursor.pos) // 01 00 02 01 00 00 00 07