Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
Just to clarify further, the code above uses 'static char outbuf' which doesn't die as it's not a local variable, it is statically allocated in memory. However, the next call to the function will overwrite the first call, so something like
printf("%s %s\n", ftoa(...), ftoa(...));
It's always a better idea to pass a buffer in, but it's wrong to say that the buffer will 'die'.
exp2 = (0xFF & (x.L >> 23)) - 127; /* JEB fixed for 16-bit char F2xxx */
The cast to unsigned char on most processors would be an AND with 0xFF, but on the T.I. 16-bit DSP, a char is 16-bit and it became an AND with 0xFFFF. This caused errors when converting negative numbers.
Also, users who want to pass in a buffer to eliminate the static char msg should be aware that ftoa() uses the sizeof( msg ) and if this doesn't match, errors will occur.