Svyatoslav Phirsov
Svyatoslav Phirsov
[Partially implemented](https://github.com/intel/tinycbor/compare/master...phirsov:get-half-as). Is this OK. or some amendment is needed?
[Look at the improvement made so far](https://github.com/intel/tinycbor/compare/master...phirsov:get-half-as). But I'm in doubt now: I have used ldexpf function, which is not accessible in plain old C89 and some antique compilers.
> Let's do bit manipulation directly Do you mean to replace the `val = ldexpf(mant + 1024, exp - 25);` with `val = ((float)mant + 1024) * (float)(1 25)
```cpp static inline float decode_halff(unsigned short half) { int exp = (half >> 10) & 0x1f; int mant = half & 0x3ff; float mantf, expf, val; if (exp == 0)...
So, there are 4 ways with their pro-s and contra-s: 1. use ldexp: standard-compliant, works on most platforms, but can be expensive; 1. use ldexpf: needs the C99 compiler, can...
OK, but I think, this is the task for separate feature request. As for now, let's roll back to plain old doubles (ldexp, not ldexpf) both for cbor_value_get_half_float_as_float and cbor_value_get_half_float_as_double.
Well, cbor_value_get_half_float_as_float needs a pointer to float, so user should do extra effort. Hope, nobody could try something like: ```c double x; /* Oops... I know a guy, who can...
[Implemented](https://github.com/intel/tinycbor/compare/master...phirsov:get-half-as). I'll squash the branch into the single commit before pull request.