C#: Storing percentages, 50 or 0.50?

I would be inclined to store them as 0 to 1, then there is no conversion required when using the number in a calculation.

Using a number between 0 and 100 is more of a display / readability way of looking at the number. When you are displaying the percentage you can use String.Format("{0:P},percentage) which will expect the number to be between 0 and 1 but will display as 0 to 100.


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.

Tags:

C#

Decimal

Types