Weird result of floating point calculations on MPC8548E

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Weird result of floating point calculations on MPC8548E

1,136件の閲覧回数
lixiong
Contributor I

Hi,

I have encountered a error when doing floating calculations, using Sourcery cross toolchain 4.5.2, and the GCC argument is "-c -fmessage-length=0 -std=c99 -msoft-float" The example is like following:

       Example:

#include <stdio.h>

#include <float.h>

int main(){

    double a = 5;

    double b = a / ((double)2);

    double c = 5 / ((double)2);

    printf ("b = %2.6lf\n", b);

    printf ("c = %2.6lf\n", c);

    return 0;

}


     running result:

     b = 0.000000

     c = 2.500000

I couldn't figure out why floating variable is not working, and this code seems to me is quite OK. So I guess that the fault should lies in somewhere of GCC configuration, but no sure.

0 件の賞賛
返信
1 返信

1,007件の閲覧回数
lixiong
Contributor I

Hi everyone. Please kindly help. THanks!

0 件の賞賛
返信