Weird result of floating point calculations on MPC8548E

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Weird result of floating point calculations on MPC8548E

825 次查看
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 回复

696 次查看
lixiong
Contributor I

Hi everyone. Please kindly help. THanks!

0 项奖励
回复