←back to thread

69 points seg_fault | 1 comments | | HN request time: 0.197s | source

Since there is so much interest on HN in floats lately and their software implementations, I wanted to show mine. It has no use and is just for teaching me floats and C++. Give me your thoughts.
Show context
fuhsnn ◴[] No.41907946[source]
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].

[1] https://ajxs.me/blog/Yamaha_DX7_Technical_Analysis.html

replies(2): >>41908010 #>>41908315 #
1. badmintonbaseba ◴[] No.41908010[source]
Possibly could be combined with C23's _BitInt(N) for the template arguments? I think it's available in clang as a C++ extension.

edit: or I guess you could have your own Tmantissa and Texponent types as custom classes that correctly model _BitInt(N), they don't seem to be required to be builtin integral types.