This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: diag_printf and float problem
- From: Tomasz Kutyla <tkutyla at marp dot pl>
- To: Gary Thomas <gary at mlbassoc dot com>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Tue, 03 Apr 2007 15:48:48 +0200
- Subject: Re: [ECOS] diag_printf and float problem
- References: <46125017.7090207@marp.pl> <4612534E.4090704@mlbassoc.com>
It seems to be some tiny problem but it happens;)
My code looks like below:
float f = 10.5;
diag_printf("Test F = %f", f);
and on the terminal I've got:
Test F = %f
Why is that??
diag_printf() doesn't support floating point. If you need to print
floating point values, you'll need to use the stdio printf() function.
Thanks Gary, now it works;) Funny thing occurs: when I use printf like this:
diag_printf("test diag\n");
printf("##Test F = %.1f", f);
system waits for some printf functions to put the stream to the
terminal. So I got:
test diag
test diag
test diag
test diag
##Test F = 10.5##Test F = 10.5##Test F = 10.5##Test F = 10.5##Test F =
10.5##Test F = 10.5##Test F = 10.5
test diag
test diag
test diag
test diag
test diag
##Test F = 10.5##Test F = 10.5##Test F = 10.5##Test F = 10.5##Test F =
10.5##Test F = 10.5##Test F = 10.5
But when I use printf like this:
diag_printf("test diag\n");
printf("##Test F = %.1f\n", f);
I got on the terminal:
test diag
##Test F = 10.5
test diag
##Test F = 10.5
test diag
##Test F = 10.5
test diag
##Test F = 10.5
I'm writing it because maybe it will help somebody in the future with
the situation like mine;)
Best regards
Tomasz;)
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss