Welcome to our site! EDAboard.com is an international Electronics 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 a friendly reminder, local variables exist on the stack, and "die" on exit of the routine. your routine would be a bit safer of you used a buffer passed in from the caller:
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(...));
won't work.
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[15] should be aware that ftoa() uses the sizeof( msg ) and if this doesn't match, errors will occur.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.