iotivity-lite
iotivity-lite copied to clipboard
Floating point number shall be accepted by double attribute
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
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.
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.
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