MikeLankamp / fpm

C++ header-only fixed-point math library
https://mikelankamp.github.io/fpm
MIT License
634 stars 77 forks source link

Provide a way to serialize fpm::fixed #37

Open Eren121 opened 2 years ago

Eren121 commented 2 years ago

Is the value returned by raw_value() the same across all platforms for a given fixed point value? That's for serialization and sending into network and ensure portability. I assume yes but just to be sure.

MikeLankamp commented 2 years ago

Hi @Eren121, it is the same in practice, but to be fair, FPM makes no guarantee for this. You could use raw_value() for now, but "officially" supporting platform-stable (and backwards-compatible) serialization would be a good feature request.

Eren121 commented 2 years ago

Thanks for your answer. So I turn this into a feature request : making fpm::fixed serialization-friendly ^^

If it is with raw_value() or another method to ensure raw_value() backward-compatibility, that's not important. Currently it could be implemented surely by serializing a char array (e.g. "1.4672") but, that seems a waste of memory space, therefore of performance.