Example usage for org.apache.commons.lang.math NumberUtils NumberUtils

List of usage examples for org.apache.commons.lang.math NumberUtils NumberUtils

Introduction

In this page you can find the example usage for org.apache.commons.lang.math NumberUtils NumberUtils.

Prototype

public NumberUtils() 

Source Link

Document

NumberUtils instances should NOT be constructed in standard programming.

Usage

From source file:ml.shifu.shifu.util.JexlTest.java

@Test
public void testMathMethod() {
    JexlEngine jexl = new JexlEngine();
    String jexlExp = "NumberUtils.max(a, b, c)";

    Expression e = jexl.createExpression(jexlExp);

    JexlContext jc = new MapContext();
    jc.set("NumberUtils", new NumberUtils());
    jc.set("a", 7);
    jc.set("b", 5);
    jc.set("c", 9);
    Assert.assertEquals(9, e.evaluate(jc));
}

From source file:ml.shifu.shifu.util.JexlTest.java

@Test
public void testDerived() {
    JexlEngine jexl = new JexlEngine();
    String jexlExp = "(0.00472217*vbase_t1_model_V2R1 + 0.00341543*vbase_t1_model_V2BM)/0.00813760";

    Expression e = jexl.createExpression(jexlExp);

    JexlContext jc = new MapContext();
    jc.set("NumberUtils", new NumberUtils());
    jc.set("vbase_t1_model_V2R1", 238);
    jc.set("vbase_t1_model_V2BM", 289);
    Assert.assertEquals(259.40519686394026, e.evaluate(jc));
}