I have these two scenarios working with bigdecimal:
BigDecimal result;
escenario 1: result = 19315859.60145000000000 ---[should be]--> 19315859.6014
escenario 2: result = 66841687.43665000000000 ---[should be]--> 66841687.4367
The problem is that I am using a variable (result) and if it is applied to this variable .setScale (4, BigDecimal.ROUND_HALF_UP)
will work with scenario 2, but not with scenario 1, the same if I use .setScale 4, BigDecimal.ROUND_HALF_DOWN)
scenario 1 will work but scenario 2 will not work .
What I want to do is that if the previous value is greater than 5, increase it by 1 and leave it as it is.
Ex:
19315859.60145000000000 : ok the previous value is 4 so y leave it and the result should be 19315859.6014.
66841687.43665000000000 : ok the previous value is 6 so y increase 1 and the result should be 66841687.4367