Mathematical operations, Math.ceil property | SoloLearn: Learn to code for FREE!

+1

Mathematical operations, Math.ceil property

Since I want an output of 14.45, I have p=14.445, If i use Output=Math.Round(p,2) ; I get the output of 14.44, I couldn't able to use math.ceiling here because it consists of two arguments, Is there is any way of getting output of 14.45?

5/31/2020 1:08:13 AM

Ashraf

8 Answers

New Answer

+5

Use this as a 3rd argument with Math.Round: MidpointRounding.AwayFromZero You can read more about it here: https://docs.microsoft.com/en-us/dotnet/api/system.math.round#System_Math_Round_System_Double_System_Int32_System_MidpointRounding_

+6

This might also be helpful to review. https://docs.microsoft.com/en-us/dotnet/api/system.midpointrounding?view=netcore-3.1

+4

Thank you coffeeunderrun David Carroll and fork() 😇🤗 it helps

+3

coffeeunderrun nope, he is referring Math.floor as above example he provided before

+2

Round accepts a third argument: Math.Round(p, 2, MidpointRounding.AwayFromZero)

+2

fork() are you are referring to using the Midpoint Rounding with Round? I just verified that I get 1.04, using your example of 1.0352, when using AwayFromZero. Unless I misunderstood what you were saying.

+2

Thank you for the clarification, Ashraf!

+1

coffeeunderrun thank you bro, could you please elaborate? I couldn't understand that