problem while detecting floating point operations - Linux

This is a discussion on problem while detecting floating point operations - Linux ; hi friends ... i am facing a problem while detecting floating point operations in my project, please help me. i want to find out the places in my C/C++ project where i am doing floating point operations. As it is ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: problem while detecting floating point operations

  1. problem while detecting floating point operations

    hi friends ...

    i am facing a problem while detecting floating point operations in my
    project, please help me.

    i want to find out the places in my C/C++ project where i am doing
    floating point operations.
    As it is a big project it is not possible to check every line manually,
    so is there any other method
    to detect floating point operations in my project?


    I just compiled the project with option '-msoft-float', it is reporting
    errors at the places where 'float' variables are being used. But it is
    not reporting any error for the places where we are using floating
    literals ...
    to make myself clear,i would give an example code snippet,

    example:

    //first case

    float x;

    printf("%f",x); // here it is reporting an error because we are
    trying to use the variable (float) x;

    //in second case

    int y;

    y = 4.5 * 2.5; // here it is not reporting any error .

    what should have to be done to detect these kind of operations
    also.

    library: GCC 3.4.3
    kernel: 2.6.9


    Thanks in advance


  2. Re: problem while detecting floating point operations

    "alex" writes:
    > int y;
    >
    > y = 4.5 * 2.5; // here it is not reporting any error .
    >
    > what should have to be done to detect these kind of operations


    Well it could be that the compiler computed 11 at compilation time and
    is only doing y=11; at run time.

    --
    __Pascal Bourguignon__ http://www.informatimago.com/

    "You cannot really appreciate Dilbert unless you read it in the
    original Klingon"

  3. Re: problem while detecting floating point operations

    On 2006-12-19, Pascal Bourguignon wrote:
    > "alex" writes:
    >> int y;
    >>
    >> y = 4.5 * 2.5; // here it is not reporting any error .
    >>
    >> what should have to be done to detect these kind of operations

    >
    > Well it could be that the compiler computed 11 at compilation time and
    > is only doing y=11; at run time.


    Yes, GCC will perform constant folding at compile time and the
    line above will be equivalent to "y = 11.0;" which requires no
    floating point operations.

    --
    Grant Edwards grante Yow! This PIZZA symbolizes
    at my COMPLETE EMOTIONAL
    visi.com RECOVERY!!

  4. Re: problem while detecting floating point operations



    On 12月19日, 下午6时18分, "alex" wrote:
    > hi friends ...
    >
    > i am facing a problem while detecting floating point operations in my
    > project, please help me.
    >
    > i want to find out the places in my C/C++ project where i am doing
    > floating point operations.
    > As it is a big project it is not possible to check every line manually,
    > so is there any other method
    > to detect floating point operations in my project?
    >
    > I just compiled the project with option '-msoft-float', it is reporting
    > errors at the places where 'float' variables are being used. But it is
    > not reporting any error for the places where we are using floating
    > literals ...
    > to make myself clear,i would give an example code snippet,
    >
    > example:
    >
    > //first case
    >
    > float x;
    >
    > printf("%f",x); // here it is reporting an error because we are
    > trying to use the variable (float) x;
    >
    > //in second case
    >
    > int y;
    >
    > y = 4.5 * 2.5; // here it is not reporting any error .
    >
    > what should have to be done to detect these kind of operations
    > also.


    How about

    egrep "[0-9].\.[0-9]." * -nr
    >
    > library: GCC 3.4.3
    > kernel: 2.6.9
    >
    > Thanks in advance



  5. Re: problem while detecting floating point operations

    thank you friends I solved the problem using some third party lexer
    thank you very much


+ Reply to Thread