@Test public void testLargeIntArgs() throws Exception { Multiply multiply = new Multiply(); assertEquals(2000000000000L * 3 * 4 * -2, multiply.execute(rhsFuncContext, Symbols.asList(syms, 2000000000000L, 3, 4, -2)).asInteger().getValue()); }
@Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkAllArgumentsAreNumeric(getName(), arguments); long i = 1; double f = 1.0; boolean float_found = false; for(Symbol arg : arguments) { IntegerSymbol ic = arg.asInteger(); if(ic != null) { if(float_found) { f *= ic.getValue(); } else { i *= ic.getValue(); } } else { if(float_found) { f *= arg.asDouble().getValue(); } else { float_found = true; f = i * arg.asDouble().getValue(); } } } final SymbolFactory syms = context.getSymbols(); return float_found ? syms.createDouble(f) : syms.createInteger(i); }
Multiply extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkAllArgumentsAreNumeric(getName(), arguments); long i = 1; double f = 1.0; boolean float_found = false; for(Symbol arg : arguments) { IntegerSymbol ic = arg.asInteger(); if(ic != null) { if(float_found) { f *= ic.getValue(); } else { i *= ic.getValue(); } } else { if(float_found) { f *= arg.asDouble().getValue(); } else { float_found = true; f = i * arg.asDouble().getValue(); } } } final SymbolFactory syms = context.getSymbols(); return float_found ? syms.createDouble(f) : syms.createInteger(i); } }
Multiply extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkAllArgumentsAreNumeric(getName(), arguments); long i = 1; double f = 1.0; boolean float_found = false; for(Symbol arg : arguments) { IntegerSymbol ic = arg.asInteger(); if(ic != null) { if(float_found) { f *= ic.getValue(); } else { i *= ic.getValue(); } } else { if(float_found) { f *= arg.asDouble().getValue(); } else { float_found = true; f = i * arg.asDouble().getValue(); } } } final SymbolFactory syms = context.getSymbols(); return float_found ? syms.createDouble(f) : syms.createInteger(i); } Multiply(); }
Multiply extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkAllArgumentsAreNumeric(getName(), arguments); long i = 1; double f = 1.0; boolean float_found = false; for(Symbol arg : arguments) { IntegerSymbol ic = arg.asInteger(); if(ic != null) { if(float_found) { f *= ic.getValue(); } else { i *= ic.getValue(); } } else { if(float_found) { f *= arg.asDouble().getValue(); } else { float_found = true; f = i * arg.asDouble().getValue(); } } } final SymbolFactory syms = context.getSymbols(); return float_found ? syms.createDouble(f) : syms.createInteger(i); } Multiply(); @Override Symbol execute(RhsFunctionContext context, List<Symbol> arguments); }
Multiply extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkAllArgumentsAreNumeric(getName(), arguments); long i = 1; double f = 1.0; boolean float_found = false; for(Symbol arg : arguments) { IntegerSymbol ic = arg.asInteger(); if(ic != null) { if(float_found) { f *= ic.getValue(); } else { i *= ic.getValue(); } } else { if(float_found) { f *= arg.asDouble().getValue(); } else { float_found = true; f = i * arg.asDouble().getValue(); } } } final SymbolFactory syms = context.getSymbols(); return float_found ? syms.createDouble(f) : syms.createInteger(i); } Multiply(); @Override Symbol execute(RhsFunctionContext context, List<Symbol> arguments);  }