Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating point number shall be accepted by double attribute #222

Open
ondrejtomcik opened this issue Mar 16, 2022 · 3 comments
Open

Floating point number shall be accepted by double attribute #222

ondrejtomcik opened this issue Mar 16, 2022 · 3 comments

Comments

@ondrejtomcik
Copy link
Contributor

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

@Oxymoron79
Copy link
Collaborator

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.

@ondrejtomcik
Copy link
Contributor Author

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.

@WAvdBeek
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants