I'm new to programing and figured out that if you are dealing with money, decimal is better to use. I noticed that if I use a if statement like,
if (salePrice < 0.01)
If salePrice is a decimal, it will not work because .01 represents a double-precision floating-point number. If I change everything to double it does work. But, I need to keep everything as a decimal and you really can't mix decimal with double as far as I know. Setting it to if (salePrice < 0)
will still show $0.00 by taking the itemCost - (itemCost * 99.99...%) is not what I want. Is there any way around this or am I stuck with if (salePrice < 1)
?
没有评论:
发表评论