Reputation: 21368
Based on this thread decimal vs double!, decimal is always used for money. What is the proper way to define percent? like TaxPercent? If it's double then for calculating amount * 8% (double) you would have to cast it. What's the proper way to define percent value (ie tax) and what would the calculation be.
Upvotes: 1
Views: 1759
Reputation: 942518
Use the 'm' suffix to specify a literal as a decimal. So it must be 0.08m to ensure a double doesn't creep into the calculation.
decimal tax = amount * 0.08m;
You'll find a list of valid suffix characters in this post.
Upvotes: 4