For "any size" I was kind of expecting arbitrary sized mantissa/exponent, can be useful for emulating weird DACs, for example, 12-bit mantissa and 3-bit exponent[1].
replies(2):
Float<uint8_t, // type of the mantissa
uint8_t, // type of the exponent
0, // lowest possible value of the mantissa
4095, // highest possible value of the mantissa
0, // lowest possible value of the exponent
7> // highest possible value of the exponent
The Float then simulates an unsigned 12bit mantissa and a 3bit exponent. Sure it still takes 16 bytes. But you could create a union with bitfields where you shrink that even further.[0] https://github.com/clemensmanert/fas/blob/58f9effbe6c13ab334...
Float<int64_t, int64_t>
Gives you a signed Mantissa with 64 bit and a signed Exponent with 64bit. Since there are numeric limits for int64_t available, Float knows the max and the min value.You could get even bigger ranges for Float by implementing your own big integer type.