Hi All ,how do i round up  this to 2 decimals:
 public override double GetPaymentAmount()
           double paymentAmount = (WeeklySalary * 52 / 12);

           return paymentAmount;


Recommended Answers

It's in your post title... see this overload of Math.Round; I think it is what you're looking for.

Jump to Post

All 3 Replies

Try this.
Math.Round(paymentAmount , 2);

Basing off assumption as I wish on no one a negative weekly salary... and "round up"...

Multiply by 100 to shift 2 dicimal places. Call math.ceiling to 'round up' then devide by 100 to anti-shift 2 decimal places. You will then be left with a number that has been rounded up with 2 decimal places.

return Math.Ceiling(paymentAmount * 100) / 100;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.