Skip to main content

Documentation Portal

RoundingRange

Parameter Name

Type

Description

Mandatory

From

Decimal

A decimal value of the range start, exclusive of the From value itself. If a range must start from 0 inclusive, the From value must be set to a negative number.

LowerTarget

Decimal

A decimal value used to calculate the target rounded value, for the numbers less than the Threshold, according to the defined Range behavior. If the LowerTarget value violates the MaxDecimalPlaces setting for the respective currency, it must be truncated as described in the “Important Notices” below.

RangeBehavior

Decimal

One of the possible values of RangeBehaviors enumeration defined below which is designed to control the way rounding range is handled. The range behavior is applied to Threshold, LowerTarget, UpperTarget and Exceptions in the RoundingExceptions list.

RoundingExceptions

List of RoundingException

List of decimal values used to calculate the exceptions for rounding, i.e. values not to apply rounding for. RangeBehaviors enumeration: see Table 1 and Table 2.

TargetBehaviorHelperValue

Decimal

A decimal value required for the “nearest target” and “relative whole target” behavior.

Threshold

Decimal

A decimal value used to split the range so that the values less than the threshold would be rounded to the Lower target, and values greater than or equal to the threshold would be rounded to the Upper target. For the "Absolute target," the threshold range is an absolute value. Other Ranges are Relative values. See the absolute target in Rounding Range for more information. RoundingRange

To

Decimal

A decimal value of the range end, inclusive.

UpperTarget

Decimal

A decimal value used to calculate the target rounded value, for the numbers greater than or equal to the Threshold, according to the defined Range behavior. If the UpperTarget value violates the MaxDecimalPlaces setting for the respective currency, it must be truncated as described in the “Important Notices” below.

Table 1: RoundingException

List of decimal values used to calculate the exceptions for rounding, i.e. values not to apply rounding for.

RangeBehaviors enumeration:

RangeBehaviors Option Value

Name

Description

1

Absolute target

In this behavior all the values within the specified range (LowerTarget, UpperTarget, Threshold and RoundingExceptions) denote the values themselves as is, without the need for any additional math operations.

Getting rounding result (R) for the source number (S) must be implemented as follows:

If (S = Exceptionn) then R = Exceptionn

If (S < Threshold) then R = LowerTarget

If (S >= Threshold) then R = UpperTarget

2

Relative Decimal target

In this behavior all the values within the specified range (LowerTarget, UpperTarget, Threshold and RoundingExceptions) represent floating point numbers between 0 (inclusive) and 1 (inclusive), used to calculate the respective absolute values, relative to the calculation base (B) as follows:

For source number (S):

B = whole part of S

LowerTarget (absolute):

LA = B – 1 + LowerTarget

UpperTarget (absolute):

UA = B + UpperTarget

Threshold (absolute):

TA = B + Threshold

Exceptionn (absolute):

EAn = B + Exceptionn

If (S = EAn) then Result (R) = EAn

If (S < TA) then R = LA

If (S >= TA) then R = UA

3

Relative Whole target

In this behavior LL the values within the specified range (LowerTarget, UpperTarget, Threshold and RoundingExceptions) represent non-negative whole numbers, while TargetBehaviorHelperValue (V) is used to determine the calculation base (B). V must be a power of 10 (10, 100, 1000, etc.) and denotes the order of magnitude for the range “split” by the Threshold. For example, if Threshold = 9 we need to know if this is 9 out of 10 or 9 out of 100.

Getting rounding result (R) for the source number (S) must be implemented as follows:

For source number (S):

B = S rounded down to the closest multiple of V

For example if (S = 56789 and V = 1000) then B = 56000

LowerTarget (absolute):

LA = B – V + LowerTarget

UpperTarget (absolute):

UA = B + UpperTarget

Threshold (absolute):

TA = B + Threshold

Exceptionn (absolute):

EAn = B + Exceptionn

If (S = EAn) then Result (R) = EAn

If (S < TA) then R = LA

If (S >= TA) then R = UA

4

Nearest target

In this behavior, LowerTarget and UpperTarget represent non-negative floating-point numbers, while TargetBehaviorHelperValue (V) is used to determine the calculation base (B). V must be a whole divisor of any power of 10 (5, 10, 25, 50, 100, 250, 500, 1000, etc.). The threshold must be any floating-point number between 0 (inclusive) and V (exclusive).

Getting rounding result (R) for the source number (S) must be implemented as follows:

For source number (S):

B = S rounded down to the closest multiple of V

For example, if (S = 123 and V = 5) then B = 120

LowerTarget (absolute):

LA = B – 1 + LowerTarget

UpperTarget  (absolute):

UA = B – 1 + V + UpperTarget

Threshold (absolute):

TA = B + Threshold

Exceptionn (absolute):

EAn = B + Exceptionn

If (S = EAn) then Result (R) = EAn

If (S < TA) then R = LA

If (S >= TA) then R = UA

Important Notices

If the result of rounding is a negative number, it must be set to zero, for any rounding behavior defined in the table above.

If either LowerTarget or UpperTarget value violates MaxDecimalPlaces setting for the respective currency, this value must be truncated accordingly. For example, if UpperTarget is set to 0.999 for USD, it must be truncated to 0.99 before using in any further calculations.

Table 2: Rounding Rules Samples

The following samples indicate how rounding X to Y (X → Y) is implemented using the respective settings.

0.25 → 0

3 → 0

1.5 → 1.5

2 → 2

22.47 → 21.95

22.48 → 22.99

22.50 → 22.50

33.75 → 33.75

2047 → 1995

2048 → 2100

122.26 → 124.99

122.25 → 119.99

127.26 → 129.99

121.50 → 121.50

127.50 → 127.50

123 → 123

128 → 128

2047 → 1999

2048 → 2100

From

0

1

1000

100

1000

To

3

250

10000

1000

10000

Threshold

3.01

0.48

48

2.26

48

LowerTarget

0

0.95

95

0.99

0

UpperTarget

0

0.99

100

0.99

1

RangeBehavior

1

Absolute

2

Relative Decimal

3

Relative Whole

4

Nearest

4

Nearest

TargetBehaviorHelperValue

100

5

100

RoundingExceptions

1.5

0.50

1.50

2

0.75

2.50

3