69 if (buffer_size >= 1) {
136 uint8_t exp = (uint8_t) ((val & 0x7F800000) >> 23);
137 uint32_t mant = val & 0x7FFFFF;
139 if (value != value) {
140 res = (uint16_t) 0x00e700;
142 res = (uint16_t) ((val & 0x80000000) >> 16 | 0x7C00 | (mant ? 1 : 0) << 15);
144 }
else if (exp == 0x00) {
145 res = (uint16_t) ((val & 0x80000000) >> 16 | mant >> 13);
147 int8_t logical_exp = (int8_t) (exp - 127);
148 assert(logical_exp == exp - 127);
151 if (logical_exp < -24) {
155 }
else if (logical_exp < -14) {
159 res = (uint16_t) (val & 0x80000000) >> 16 | (uint16_t) (1 << (24 + logical_exp));
161 res = (uint16_t) ((val & 0x80000000) >> 16 | ((((uint8_t) logical_exp) + 15) << 10) | (uint16_t) (mant >> 13));
size_t cbor_encode_map_start(size_t length, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_break(unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_half(float value, unsigned char *buffer, size_t buffer_size)
Encodes a half-precision float.
size_t cbor_encode_indef_array_start(unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_string_start(size_t length, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_negint32(uint32_t value, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_ctrl(uint8_t value, unsigned char *buffer, size_t buffer_size)
size_t _cbor_encode_uint16(uint16_t value, unsigned char *buffer, size_t buffer_size, uint8_t offset)
size_t _cbor_encode_uint64(uint64_t value, unsigned char *buffer, size_t buffer_size, uint8_t offset)
size_t cbor_encode_negint8(uint8_t value, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_uint64(uint64_t value, unsigned char *buffer, size_t buffer_size)
size_t _cbor_encode_byte(uint8_t value, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_single(float value, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_null(unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_bool(bool value, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_indef_map_start(unsigned char *buffer, size_t buffer_size)
size_t _cbor_encode_uint32(uint32_t value, unsigned char *buffer, size_t buffer_size, uint8_t offset)
size_t cbor_encode_double(double value, unsigned char *buffer, size_t buffer_size)
size_t _cbor_encode_uint(uint64_t value, unsigned char *buffer, size_t buffer_size, uint8_t offset)
size_t cbor_encode_array_start(size_t length, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_uint8(uint8_t value, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_uint16(uint16_t value, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_negint64(uint64_t value, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_uint32(uint32_t value, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_undef(unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_negint(uint64_t value, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_indef_string_start(unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_uint(uint64_t value, unsigned char *buffer, size_t buffer_size)
size_t _cbor_encode_uint8(uint8_t value, unsigned char *buffer, size_t buffer_size, uint8_t offset)
size_t cbor_encode_bytestring_start(size_t length, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_indef_bytestring_start(unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_negint16(uint16_t value, unsigned char *buffer, size_t buffer_size)
size_t cbor_encode_tag(uint64_t value, unsigned char *buffer, size_t buffer_size)