com.codetaco.math.function.FuncKm2Mi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of math Show documentation
Show all versions of math Show documentation
Equation processing for Java
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)";
}
}