Closed andi-huber closed 11 months ago
I was away for a few days, but will have a look tomorrow.
Found a view more optimization candidates today. Implemented these. Now PR is ready for review.
Why are some methods like
@Override boolean isZero(Number number) { return ((AtomicInteger) number).intValue() == 0; } },
casting directly to e.g.
AtomicInteger
while other methods check forinstanceof
before?
Hi Werner. If we do the isZero(Number number)
checks within the (private) enum NumberType
, an instanceof
check is no longer required, because we already know what type the number parameter has. This is implicit knowledge, which I did not have a good idea how to communicate better within the code or comments.
Improvements:
boolean isInteger(NumberType numberType, Number number)
Number narrow(Number number)
BigDecimal
like 1234.000 (note the trailing zeros)isZero(Number)
check intoNumberType
, and provide optimized variants forRationalNumber
,BigInteger
andBigDecimal
multiplyWideAndNarrow(...)
if any of the operands is zero.This change is