artyom-beilis / float16

half float library for C and for z80
MIT License
32 stars 7 forks source link

Conversion to/from float #1

Open nemequ opened 4 years ago

nemequ commented 4 years ago

It would be nice to be able to convert to/from standard floats. Generically if possible, but at least if the system is using IEEE 754 (__STDC_IEC_559__ should be defined, though TBH I wouldn't be surprised if an MSVC exception is necessary).

FWIW, I'm considering this as a way to implement the float16_t stuff in NEON portably in SIMDe. I'm going to open a couple more issues, I just wanted you to understand the perspective I'm looking at it from since you seem to be focused on retrocomputing and so probably have different things in mind. If you're not interested in supporting my use case that's fine; please feel free to just close the issues if that's the case.

artyom-beilis commented 4 years ago

Yes you are right. I indeed need to expose to/from float at least for C API

artyom-beilis commented 4 years ago

Just for the record - it isn't high performance library - there are good libraries for c++ like half.hpp and for most modern systems it is better to do f16 math via conversion to float32 (with exception of arm that supports float16 natively in simd)

nemequ commented 4 years ago

Yes, converting to float is my plan, I was just thinking this could be interesting if all that's available is softfp, but obviously I'd have to do some benchmarking. Also, C++ isn't an option; it would be nice to have something available in C.