I'd use frexp to get mantissa and exponent.
man frexp (Not sure where ldexp comes in, but hey, [s]he's your teacher and it's your homework.)
You can probably build on your
fractbin function, passing it the exponent so it can put the decimal point in the right place. You may not need
intbin at all. Anyway, you'll have to distinguish three cases:
(A) Start with "0.00...0" for small numbers -- less than 1 or 0.5, depending on your design.
(B) Put the period ("decimal point", now rather binary point) somewhere within the mantissa for middle numbers.
(C) Finish with "000...0" for large numbers -- greater or equal 2**54, I think. (Why 54? According to my /usr/include/ieee754.h, my doubles have a mantissa stored in 32+20 bits, and there's a leading 1. Yours might differ, but I doubt it. But you'll have to work out the details.)
Extra Hints:
- Normally I'd write this using a for or while loop instead of recursion. It uses less computer resources (probably a minor concern of yours), and might be easier to understand. A C++ type trait should tell you ahead of time how many bits your mantissa has.
- See if your program works for negative numbers.
- Do you handle subnormal numbers correctly? Probably frexp is taking care of the details.