iotivity-lite icon indicating copy to clipboard operation
iotivity-lite copied to clipboard

Floating point number shall be accepted by double attribute

Open ondrejtomcik opened this issue 2 years ago • 3 comments

The CBOR serializers to optimize the transfer size serializes double to floating-point numbers. Currently, the IoTivity-Lite won't deserialize floating-point numbers to double attributes.

It would be very welcome to support the deserialization of floating-point numbers to attributes of types double.

Note: Test with double arrays. Where: https://github.com/iotivity/iotivity-lite/blob/master/api/oc_rep.c#L348

ondrejtomcik avatar Mar 16 '22 12:03 ondrejtomcik

Shouldn't iotivity-lite rather add support for floating point numbers instead? As double uses twice the space as float (see https://en.cppreference.com/w/cpp/language/types), iotivity-lite should make use of the memory space savings that would come with the support of floating point types, IMO.

Oxymoron79 avatar Mar 29 '22 13:03 Oxymoron79

Sure, supporting float would be nice as well. But if the float is received and the attribute is of type double, it should be successfully deserialized to double. That's what causes the issue.

ondrejtomcik avatar Mar 29 '22 17:03 ondrejtomcik

OCF only does JSON numbers, what is below is not really relevant.. so we could map a CBOR float to double in the underlaying code

WAvdBeek avatar Apr 21 '22 07:04 WAvdBeek