I also have a standalone Prolog approach (using SWI-Prolog unsure about portability):
float_bits(_, N, -1, _, N) :- !.
float_bits(Bs, N, Bit, Div, Ans) :-
Nn is N + (getbit(Bs, Bit) * Div),
DivN is Div / 2,
BitN is Bit - 1,
float_bits(Bs, Nn, BitN, DivN, Ans).
float_bits(Bs, N) :- float_bits(Bs, 1, 22, 0.5, N).
floating(Fl) -->
[A, B, C, D],
{ [A,B,C,D] ins 0..255,
Sign is (-1)**((A /\ 0b1000_0000) >> 7),
Exp_ is (A /\ 0b0111_1111) << 1 + (B /\ 0b1000_0000) >> 7,
Exp is 2**(Exp_ - 127),
FracBits is (B /\ 0b0111_1111)<<16 + C<<8 + D,
float_bits(FracBits, Frac),
Fl is Sign * Exp * Frac }.
Test example:
?- phrase(floating(0.15625),
[0b0011_1110, 0b0010_0000, 0b0000_0000, 0b00000000]).
true.