1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-11-19 00:49:32 -08:00

Merge the new edge cases.

This commit is contained in:
Danila Fedorin 2017-08-04 13:32:06 -07:00
commit 8b9892636d

View File

@ -331,12 +331,19 @@ public class StandardPlugin extends Plugin {
public static final Operator OP_CARET = new Operator(OperatorAssociativity.RIGHT, OperatorType.BINARY_INFIX, 2, new Function() { public static final Operator OP_CARET = new Operator(OperatorAssociativity.RIGHT, OperatorType.BINARY_INFIX, 2, new Function() {
@Override @Override
protected boolean matchesParams(NumberInterface[] params) { protected boolean matchesParams(NumberInterface[] params) {
return params.length == 2; return params.length == 2
&& !(params[0].compareTo(NaiveNumber.ZERO.promoteTo(params[0].getClass())) == 0
&& params[1].compareTo(NaiveNumber.ZERO.promoteTo(params[1].getClass())) == 0);
} }
@Override @Override
protected NumberInterface applyInternal(NumberInterface[] params) { protected NumberInterface applyInternal(NumberInterface[] params) {
return FUNCTION_EXP.apply(FUNCTION_LN.apply(params[0]).multiply(params[1])); if (params[0].compareTo(NaiveNumber.ZERO.promoteTo(params[0].getClass())) == 0) {
return NaiveNumber.ZERO.promoteTo(params[0].getClass());
} else if (params[1].compareTo(NaiveNumber.ZERO.promoteTo(params[0].getClass())) == 0) {
return NaiveNumber.ONE.promoteTo(params[1].getClass());
}
return FUNCTION_EXP.apply(FUNCTION_LN.apply(FUNCTION_ABS.apply(params[0])).multiply(params[1]));
} }
}); });
/** /**