Kistler-Group / sdbus-cpp

High-level C++ D-Bus library for Linux designed to provide easy-to-use yet powerful API in modern C++
GNU Lesser General Public License v2.1
309 stars 133 forks source link

Support for serializing 32-bit floats #451

Closed Martsva closed 1 month ago

Martsva commented 1 month ago

We are sending a lot of floating point numbers which do not need the precision provided by the data type double. To reduce the size and overhead of the messages it would be nice to be able to serialize float values.

Is this as simple as making new overloads for

Message& operator<<(double item); and Message& operator>>(double& item); ?

Thanks

sangelovic commented 1 month ago

D-Bus specification defines IEEE 754 double-precision floating point only among its basic types. sd-bus API (that sdbus-c++ is built on) follows that and expects this representation for serialization. Which is double type in C/C++.

So with that I don't think sdbus-c++ can in any way help you with floats.