-
Can't printf double
I'm using vxworks 6.4, and somehow I couldn't do anything with the
double variable. It didn't give me error when I declare it tho, but
when I use this variable, my program will hang.
For example:
.....
double temp;
printf("temp = %f", temp);
.....
//or
double temp;
double temp2;
temp2 = temp2 + temp;
....
Why is this not working??
For some reason, i didn't compile the project in windriver workbench,
I used cygwin to compile and then download it to the target using
workbench 2.6. One of the reason that I can think of is the way my
compiler compile double is in a different format than the format the
target board wants. Am i right? If so, how can I fix that??
Thanks in advance
-
Re: Can't printf double
Aggie wrote:[color=blue]
> I'm using vxworks 6.4, and somehow I couldn't do anything with the
> double variable. It didn't give me error when I declare it tho, but
> when I use this variable, my program will hang.
>
> For example:
>
> ....
> double temp;
> printf("temp = %f", temp);
> ....
> //or
> double temp;
> double temp2;
> temp2 = temp2 + temp;
> ...
>
> Why is this not working??[/color]
Because %f is for *FLOAT*, not double.
Try printf("temp = %lf\n", temp);
-
Re: Can't printf double
No, i can't even do,
printf("temp = %f\n", 1.1);
On Sep 11, 10:35 am, red floyd <no.s...@here.dude> wrote:[color=blue]
> Aggie wrote:[color=green]
> > I'm using vxworks 6.4, and somehow I couldn't do anything with the
> > double variable. It didn't give me error when I declare it tho, but
> > when I use this variable, my program will hang.[/color]
>[color=green]
> > For example:[/color]
>[color=green]
> > ....
> > double temp;
> > printf("temp = %f", temp);
> > ....
> > //or
> > double temp;
> > double temp2;
> > temp2 = temp2 + temp;
> > ...[/color]
>[color=green]
> > Why is this not working??[/color]
>
> Because %f is for *FLOAT*, not double.
>
> Try printf("temp = %lf\n", temp);- Hide quoted text -
>
> - Show quoted text -[/color]
-
Re: Can't printf double
Aggie wrote:
[color=blue]
>
> On Sep 11, 10:35 am, red floyd <no.s...@here.dude> wrote:[color=green]
>> Aggie wrote:[color=darkred]
>>> I'm using vxworks 6.4, and somehow I couldn't do anything with the
>>> double variable. It didn't give me error when I declare it tho, but
>>> when I use this variable, my program will hang.
>>> For example:
>>> ....
>>> double temp;
>>> printf("temp = %f", temp);
>>> ....
>>> //or
>>> double temp;
>>> double temp2;
>>> temp2 = temp2 + temp;
>>> ...
>>> Why is this not working??[/color]
>> Because %f is for *FLOAT*, not double.
>>
>> Try printf("temp = %lf\n", temp);- Hide quoted text -
>>[/color]
> No, i can't even do,
> printf("temp = %f\n", 1.1);
>[/color]
Again, 1.1 is a *DOUBLE* constant. %f is for *FLOAT*. %lf is for double.
-
Re: Can't printf double
On Sep 11, 7:14 pm, Aggie <c.kevin....@gmail.com> wrote:[color=blue]
> I'm using vxworks 6.4, and somehow I couldn't do anything with the
> double variable. It didn't give me error when I declare it tho, but
> when I use this variable, my program will hang.
>
> For example:
>
> ....
> double temp;
> printf("temp = %f", temp);
> ....
> //or
> double temp;
> double temp2;
> temp2 = temp2 + temp;
> ...
>
> Why is this not working??
> For some reason, i didn't compile the project in windriver workbench,
> I used cygwin to compile and then download it to the target using
> workbench 2.6. One of the reason that I can think of is the way my
> compiler compile double is in a different format than the format the
> target board wants. Am i right? If so, how can I fix that??
>
> Thanks in advance[/color]
Have you tried to compile your project in workbench? Are there any
compiler warnings?
-
Re: Can't printf double
On Sep 12, 3:14 am, red floyd <no.s...@here.dude> wrote:[color=blue]
> Aggie wrote:
>[color=green]
> > On Sep 11, 10:35 am, red floyd <no.s...@here.dude> wrote:[color=darkred]
> >> Aggie wrote:
> >>> I'm using vxworks 6.4, and somehow I couldn't do anything with the
> >>> double variable. It didn't give me error when I declare it tho, but
> >>> when I use this variable, my program will hang.
> >>> For example:
> >>> ....
> >>> double temp;
> >>> printf("temp = %f", temp);
> >>> ....
> >>> //or
> >>> double temp;
> >>> double temp2;
> >>> temp2 = temp2 + temp;
> >>> ...
> >>> Why is this not working??
> >> Because %f is for *FLOAT*, not double.[/color][/color]
>[color=green][color=darkred]
> >> Try printf("temp = %lf\n", temp);- Hide quoted text -[/color][/color]
>[color=green]
> > No, i can't even do,
> > printf("temp = %f\n", 1.1);
> >[/color]
>
> Again, 1.1 is a *DOUBLE* constant. %f is for *FLOAT*. %lf is for double.- Hide quoted text -
>
> - Show quoted text -[/color]
You need to include "INCLUDE_FLOATING_POINT" which includes floatLib.
In Tornado 2.1.2, Include the component "fpp formating for
printf" (Operating System Components -> IO system components -> fpp
formating for printf).
Thanks,
Ramsenthil.