C#: Storing percentages, 50 or 0.50?

后端 未结 5 1025
情书的邮戳
情书的邮戳 2021-02-19 10:53

When holding percentage values in variables is there a preference between holding them as whole numbers vs fractions. That is should the variable hold numbers between 0 and 100

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-19 11:26

    If you are using floating point fields (float, decimal, double), then 50.0 and 0.50 will have the same degree of precision. So, from this point, I would make decisions based on what similar fields in similar tables do, to give a sense of design unity.

提交回复
热议问题