Can't printf double - VxWorks

This is a discussion on Can't printf double - VxWorks ; 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 ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Can't printf double

  1. 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


  2. Re: Can't printf double

    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.

    Try printf("temp = %lf\n", temp);

  3. 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 wrote:
    > 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.
    >
    > Try printf("temp = %lf\n", temp);- Hide quoted text -
    >
    > - Show quoted text -




  4. Re: Can't printf double

    Aggie wrote:

    >
    > On Sep 11, 10:35 am, red floyd wrote:
    >> 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.
    >>
    >> Try printf("temp = %lf\n", temp);- Hide quoted text -
    >>

    > No, i can't even do,
    > printf("temp = %f\n", 1.1);
    >


    Again, 1.1 is a *DOUBLE* constant. %f is for *FLOAT*. %lf is for double.


  5. Re: Can't printf double

    On Sep 11, 7:14 pm, 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??
    > 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


    Have you tried to compile your project in workbench? Are there any
    compiler warnings?


  6. Re: Can't printf double

    On Sep 12, 3:14 am, red floyd wrote:
    > Aggie wrote:
    >
    > > On Sep 11, 10:35 am, red floyd wrote:
    > >> 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.

    >
    > >> Try printf("temp = %lf\n", temp);- Hide quoted text -

    >
    > > No, i can't even do,
    > > printf("temp = %f\n", 1.1);
    > >

    >
    > Again, 1.1 is a *DOUBLE* constant. %f is for *FLOAT*. %lf is for double.- Hide quoted text -
    >
    > - Show quoted text -


    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.


+ Reply to Thread