Floating point arithmetic is too reliable

前端 未结 9 1397
無奈伤痛
無奈伤痛 2021-01-16 09:45

I understand that floating point arithmetic as performed in modern computer systems is not always consistent with real arithmetic. I am trying to contrive a small C# progra

9条回答
  •  天命终不由人
    2021-01-16 10:06

    Try performing repeated operations on an irrational number (such as a square root) or very long length repeating fraction. You'll quickly see errors accumulate. For instance, compute 1000000*Sqrt(2) vs. Sqrt(2)+Sqrt(2)+...+Sqrt(2).

提交回复
热议问题