Commit 81595ed4 authored by Robert Lubos's avatar Robert Lubos Committed by Christopher Friedt
Browse files

net: lwm2m: Fix binary to float32_value_t conversion



The helper function to conver 32-bit binary float value to
float32_value_t incorrectly identified the "hidden" bit, resulting in
invalid conversion when TLV encoding was used to write a resource
(the output value was divided by 2).

Signed-off-by: default avatarRobert Lubos <robert.lubos@nordicsemi.no>
parent 36a72dd1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -197,8 +197,8 @@ int lwm2m_b32_to_f32(uint8_t *b32, size_t len, float32_value_t *f32)
	/* remove bias */
	e -= 127;

	/* enable "hidden" fraction bit 23 which is always 1 */
	f  = ((int32_t)1 << 22);
	/* enable "hidden" fraction bit 24 which is always 1 */
	f  = ((int32_t)1 << 23);
	/* calc fraction: bits 22-0 */
	f += ((int32_t)(b32[1] & 0x7F) << 16);
	f += ((int32_t)b32[2] << 8);