IntFromBytesBE
Description
Create an integer from big-endian bytes.
Parameters
| Name | Direction | Description |
|---|---|---|
bytes |
in | Source byte buffer holding the magnitude in big-endian order (most significant byte first). May be NULL when len == 0. |
len |
in | Number of bytes to read from bytes. |
alloc |
in | Allocator to bind to the returned integer. |
Success
Returns a normalised Int holding the unsigned magnitude packed in bytes. bytes is not modified.
Failure
Returns a zero-initialised Int bound to alloc when an intermediate shift or add allocation fails. The caller cannot distinguish that from a true zero result. LOG_FATAL when bytes is NULL and len != 0.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.Convert.c:85:
u8 bytes[] = {0x12, 0x34, 0x56, 0x78};
u8 out[4] = {0};
Int value = IntFromBytesBE(bytes, sizeof(bytes), ALLOCATOR_OF(&alloc));
u64 written = IntToBytesBE(&value, out, sizeof(out));
Str text = IntToHexStr(&value);
Last updated on