C# rounding differently depending on platform?

后端 未结 4 1629
花落未央
花落未央 2020-12-01 18:29

I have this tiny piece of code

double s = -2.6114289999999998;
double s7 = Math.Round(s, 7);
double s5 = Math.Round(s, 5);
double s6 = Math.Round(s, 6);
         


        
4条回答
  •  抹茶落季
    2020-12-01 18:49

    The value -2.611429 cannot be represented using 64-bit floating point. When compiling in 32-bit mode the value will instead use 80-bit (extended precision).

提交回复
热议问题