AnsweredAssumed Answered

How to print a float variable?

Question asked by Daniel Rodriguez Vara on Jul 3, 2009
Latest reply on Jul 6, 2009 by Daniel Rodriguez Vara

Hello.

In my program I want print or save in file some variables.

When I program this above,it does not work.

 

float i=1.234;

printf ("Variable= %f", i);

 

Then, I need to program this:

float i=1.234;

int j;

i=1.234*1000;

j=i/1000;

i=i-(j*1000);   //the operator % does not work.

printf ("Variable= %d.%d",j,i); //It work!

 

This situation occurs in printf and sprintf.

 

Anyone can solve it?

Thank you.

Outcomes