This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

printf doesn't display double value

Other Parts Discussed in Thread: MATHLIB

Hi,

I know this is a very simple question. I just found this issue when want to display a double output using printf:

with processing_time = 8096,

printf("\nEncoding time: %f seconds.\n", (double)processing_time/1000);

Display:

Encoding time:  seconds

However, when I use integer

printf("\nEncoding time: %d seconds.\n", (int)processing_time/1000);

Display:

Encoding time: 8 seconds

I spent almost half hour on this. This is surely not a problem on my VStudio.

 

Kind regards

Rizuan

  • Check these posts below.

    http://stackoverflow.com/questions/7134547/gcc-printf-and-long-double-leads-to-wrong-output-c-type-conversion-messes-u

    http://processors.wiki.ti.com/index.php/Printf_support_in_compiler

  • Hi Renjith,

    I've already enabled "full" --printf_support. I've changed from %f (double) to %Lf (long double), which print out 'f', %Lg (also long double), which print out 'g'. Any other work around? I also changed printf to platform_write. It gave me the same output; no output for the double variable.

    I also has checked the "Enable CIO function use" inside the debug configuration. Otherwise I believe I will not have any output inside the console.

    Thanks.

    Rizuan

  • Hi,

    I've found a solution to my problem. I'm using mathlib, dsplib library. I don't remember why I enabled --priority (Build->C6000 Linker->File Search Path). When I uncheck this option, my printf can output the double to my console.

    Hope someone can benefit from this post. I'm using OpenMP, and my .cio is in L2SRAM, TMDSEVMC6678L board.

    Thanks for the reply.

    Rizuan