There are at least two things to improve here:
-
Allow the client to make the floating point number itself by calling a new generic function with the individual pieces (desired type, sign, exponent, …).
-
Provide a default implementation that uses a more efficient and/or more numerically stable algorithm.
Potentially relevant: https://dl.acm.org/doi/pdf/10.1145/93548.93557