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

com.codetaco.math.function.FuncKm2Mi Maven / Gradle / Ivy

There is a newer version: 6.2.0
Show newest version
package com.codetaco.math.function;

import com.codetaco.math.Function;
import com.codetaco.math.ValueStack;
import com.codetaco.math.token.TokVariable;

public class FuncKm2Mi extends Function {
    public FuncKm2Mi() {
    }

    public FuncKm2Mi(final TokVariable var) {
        super(var);
    }

    @Override
    public void resolve(final ValueStack values) throws Exception {
        if (values.size() < 1) {
            throw new Exception("missing operand for " + toString());
        }

        Double kilometersPerMile = 1.609344;
        Double kilometers = values.popDouble();

        values.push(kilometers / kilometersPerMile);
    }

    @Override
    public String toString() {
        return "function(km2mi)";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy