All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nutz.el.opt.arithmetic.DivOpt Maven / Gradle / Ivy

Go to download

Nutz, which is a collections of lightweight frameworks, each of them can be used independently

There is a newer version: 1.r.72
Show newest version
package org.nutz.el.opt.arithmetic;

import org.nutz.el.opt.TwoTernary;

/**
 * 除
 * @author juqkai([email protected])
 *
 */
public class DivOpt extends TwoTernary {

    public int fetchPriority() {
        return 3;
    }

    public Object calculate() {
        Number lval = (Number) calculateItem(this.left);
        Number rval = (Number) calculateItem(this.right);
        if(rval instanceof Double || lval instanceof Double){
            return lval.doubleValue() / rval.doubleValue();
        }
        if(rval instanceof Float || lval instanceof Float){
            return lval.floatValue() / rval.floatValue();
        }
        if(rval instanceof Long || lval instanceof Long){
            return lval.longValue() / rval.longValue();
        }
        return lval.intValue() / rval.intValue();
    }
    
    public String fetchSelf() {
        return "/";
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy