package Reldb.RelUserCode;

import org.reldb.rel.v0.types.*;
import org.reldb.rel.v0.types.builtin.*;
import org.reldb.rel.v0.types.userdefined.*;
import org.reldb.rel.v0.values.*;
import org.reldb.rel.v0.vm.Context;

public class op_RINT__RATIONAL {
	private static final ValueRational do_RINT(Context context, ValueRational a) {
		       
		// Returns the RATIONAL value that is closest in value to the argument
		// and is equal to a mathematical integer.
			return ValueRational.select(context.getGenerator(), Math.rint(a.doubleValue()));
	}

	public static final void execute(Context context) {
		ValueRational p0 = (ValueRational)context.pop();
		context.push(do_RINT(context, p0));
	}
}