algorithm - Round off Decimals(Price) to .50 or whole numbers. C# winforms -
hi guys item prices in system generated system , round up.
like this: 1.01 1.49 1.50 , 1.51 1.99 2.00
examples: 5.56 -> 6.00 , 5.32 -> 5.50
how can achieve this? thank you.
rounding done using math.ceiling
method.
applying method directly round nearest dollar. trick rounding nearest 50 cents double price, take ceiling, , returning half of result:
decimal roundedtofiftycents = math.ceiling(2 * originalprice) / 2;
Comments
Post a Comment