Hi,

I'm creating a new utilities module and I'm trying to decide whether to keep 
the below code block (Contained in the Precision.roundUnscaled() method - BTW 
it contains a new exception type I'm playing with - see 
https://github.com/firefly-math/firefly-math-exceptions if interested - the 
utilities module will be published soon putting the new exception code to 
validated use ... hopefully - anyways here's the block):

        case BigDecimal.ROUND_UNNECESSARY:
            if (unscaled != FastMath.floor(unscaled)) {
                throw new 
MathException(ExceptionTypes.MATH_ARITHMETIC_EXCEPTION);
            }
            break;

So I would pass in the unscaled argument and say that rounding is not 
necessary.  Then if the exception is thrown, I know that presumably I should 
have chosen one of the other BigDecimal rounding operations...?

To me it seems simpler to check for the required operation like this before 
proceeding:

if (unscaled != FastMath.floor(unscaled)) {
// If necessary throw an application specific exception
}

Unless I'm missing something big, I'll remove the above code block, as well as 
the MATH_ARITHMETIC_EXCEPTION in the firefly-math-utilities module....WDYT?

Cheers,
- Ole


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to