Cosmic UK Cosmic US Cosmic Germany Cosmic Italia Cosmic France


Cosmic Software Frequently Asked Questions


When I use printf() and sprintf() with float arguments and include the floating point library (libf) in my link command file, why do I get the unexpected results?


The compiler strictly follows ANSI rules, which by default promotes single precision values to double precision values when calling libraries. Hence all 4-byte floats are converted to 8-byte doubles according to ANSI rules. If you do not wish to use doubles in your application, compile all your source files with the +sprec option and link with the libf library. This will permit the compiler to use single precision floats even when doubles are declared.