IntToBytesBE
IntToBytesBE
Description
Export an integer into big-endian bytes.
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | Integer to export |
bytes |
out | Destination buffer |
max_len |
in | Maximum bytes to write |
Usage example (from documentation)
u64 written = IntToBytesBE(&value, buffer, sizeof(buffer));Returns
Number of bytes written. Large values are truncated to the least-significant max_len bytes.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:2628:
}
(void)IntToBytesBE(value, buffer, byte_len);
write_char_internal(o, fmt_info->flags, (const char *)buffer, byte_len);
FREE(buffer);- In
Int.c:445:
}
u64 IntToBytesBE(Int *value, u8 *bytes, u64 max_len) {
ValidateInt(value);- In
Int.Convert.c:75:
u8 out[4] = {0};
Int value = IntFromBytesBE(bytes, sizeof(bytes));
u64 written = IntToBytesBE(&value, out, sizeof(out));
Str text = IntToHexStr(&value);
bool test_int_to_bytes_be_zero_max_len(void) {
WriteFmt("Testing IntToBytesBE zero max_len handling\n");
Int value = IntFrom(1); u8 byte = 0;
IntToBytesBE(&value, &byte, 0);
return false;
}
Last updated on