Asymmetric Rounding "Rounding-Half-Down"

Juggler_IN

Active Member
Joined
Nov 19, 2014
Messages
349
Office Version
  1. 2003 or older
Platform
  1. Windows
While I have been able to code a function for Asymmetric Rounding "Rounding-Half-Up" (code attached). But, I am struggling with Asymmetric Rounding "Rounding-Half-Down" method.

Code:
Public Function RoundHalfUpAsym( _
       ByVal myNum As Double, _
       ByVal myFac As Double) As Double
        
        RoundHalfUpAsym = Int(myNum * CDec(10# ^ myFac) + 0.5) / CDec(10# ^ myFac)


End Function

The concept of Asymmetric Rounding "Rounding-Half-Down" can be referenced at:
HTML:
https://www.eetimes.com/document.asp?doc_id=1274515#A4
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi,
Try this code:
Rich (BB code):
Function RoundHalfDownAsym(myNum As Double, myFac As Integer) As Double
  If myNum < 0 Then
    RoundHalfDownAsym = WorksheetFunction.RoundUp(myNum, myFac)
  Else
    RoundHalfDownAsym = WorksheetFunction.RoundDown(myNum, myFac)
  End If
End Function
Regards
 
Last edited:
Upvote 0
@ZVI;

No, it doesn't work.

-2.0000-1.7000-1.5000-1.3000-1.0000-0.7000-0.5000-0.30000.00000.30000.50000.70001.00001.30001.50001.70002.0000
Expected-2-2-2-1-1-1-1-0000111122
Actual-2-2-2-2-1-1-1-1000011112
...Error...Error...Error...Error.

<colgroup><col span="18"></colgroup><tbody>
</tbody>
 
Upvote 0
No, it doesn't work.
My bad, use the bellow code:
Rich (BB code):
Function RoundHalfDownAsym(V As Double, Optional DecPlaces As Integer = 0) As Double
' ZVI:2019-08-26 https://www.mrexcel.com/forum/excel-questions/1108001-asymmetric-rounding-rounding-half-down.htm
  If DecPlaces < 0 Then
    RoundHalfDownAsym = Round(V / 10 ^ -DecPlaces - Sgn(V) * V * 2E-16, 0) * 10 ^ -DecPlaces
  Else
    RoundHalfDownAsym = Round(V - Sgn(V) * V * 2E-16, DecPlaces)
  End If
  If Abs(RoundHalfDownAsym) = 0 Then RoundHalfDownAsym = 0
End Function
Book1
ABCD
1ValueExpectedActual
2-2-2-2copy C2 down
3-1.5-2-2
4-1.3-1-1
5-1-1-1
6-0.7-1-1
7-0.5-1-1
8-0.300
9000
100.300
110.500
120.711
13111
141.311
151.511
161.722
17222
Sheet1
Cell Formulas
RangeFormula
C2=RoundHalfDownAsym(A2)

Regards
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top