Proper code to do this doesn't do any tests. Just grab the bytes from the order of the transfer format (in this case network order) into the order of the abstract machine in C. The compiler will turn that into whatever is needed depending on if it's compiling to a big-endian or little-endian machine and may use byteswap instructions if needed. Having tests in the code is a code smell that creates unchecked paths to the code that are much more likely to be wrong as they are not used most of the time.
Or it may not because often compilers fail to make simple optimizations:
The point is that you can't rely on compilers consistently to recognize complex patterns.
And even if the compiler doesn't always optimize ideally my original point still stands. Delegating this to the compiler instead of trying to manually call swap instructions is a much better way of going about it.
(Lossless base10 encoding of 0.3 single precision would be like "10066330*2^-25"..not very readable).
If you have to use strings as the intermediate representation (why?) Then printf("%x") and scanf("%x") is perfectly lossless and widespread.
The only thing that's lossy is converting floats to decimal point numbers, which is absolutely silly if it's just two machines communicating.