C compiler bug (floating point arithmetic)?

后端 未结 3 1466
北海茫月
北海茫月 2020-12-04 04:26
#include

int main()
{
    double fract=0;
    int tmp;

    //scanf(\"%lf\",&fract);
    fract=0.312;
    printf(\"%lf\",fract);
    printf(\"\\n         


        
3条回答
  •  执笔经年
    2020-12-04 04:39

    So you multiplied 0.3119999999999999999895916591441391574335284531116485595703125 by 1000 and truncated it and got 311? I don't see where the problem is.

提交回复
热议问题