Why does adding 0 to the end of float literal change how it rounds (possible GCC bug)?

前端 未结 4 394
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 10:08

I discovered on my x86 VM (32 bit) that the following program:

#include 
void foo (long double x) {
    int y = x;
    printf(\"(int)%Lf = %d\         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-03 10:43

    Double values, when there is not enough precision to represent a value, rounds up or down to the closest one. In your implementation it is rounding up to 1.

提交回复
热议问题