Rounding differences on Windows vs Unix based system in sprintf

前端 未结 4 1939
天涯浪人
天涯浪人 2020-12-19 01:38

I have problem on UNIX based systems sprintf does not round up properly value.

For example

double tmp = 88888888888885.875
char out[512];
         


        
4条回答
  •  醉酒成梦
    2020-12-19 02:28

    That's because you're using double which has accuracy limitations, meaning, your 88888888888885.875 is probably being rounded to something else internally.

    See more info in a similar question, in blogs or in wikipedia.

提交回复
热议问题