Home > Articles > Details

Rounding Down to the Nearest Decimal Point in C-Sharp (AspNet 6)


Question: How do you Round Down the number to the nearest decimal point in C#? the number I want to round down is 0.7777777777777777771, when I round use
Math.Round(MyNumber,02) the answer is 0.78. I don't want this answer, I wanted 0.77.

How do you do that with Math.Round() Method?

Login to See the Rest of the Answer

Answer:
See the code below:

decimal myRoundDownValue = Math.Round(MyNumber,2,MidpointRounding.ToNegativeInfinity);
//                          
                            
                                
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

Hy said:

If you want to get a positive number from a subtraction in C sharp just use Decimals and absolute values.

Posted On: March 02, 2022 13:30:03 PM

© 2022 - ErnesTech - Privacy