Conversion of a decimal to double number in C# results in a difference

前端 未结 5 1821
我寻月下人不归
我寻月下人不归 2020-11-30 00:44

Summary of the problem:

For some decimal values, when we convert the type from decimal to double, a small fraction is added to the result.

What makes it wors

5条回答
  •  醉酒成梦
    2020-11-30 01:07

    This is an old problem, and has been the subject of many similar questions on StackOverflow.

    The simplistic explanation is that decimal numbers can't be exactly represented in binary

    This link is an article which might explain the problem.

提交回复
热议问题