/** Our internal representation of a number in the N0 language. * See http://www.radford.edu/itec380/2009fall-ibarland/Hw06/hw06.html * * @author Ian Barland * @version 2008.Nov.30 */ public class Num extends Value { private double x; Num( double _x ) { this.x = _x; } public String toString() { // Let's make ints look better than, say, "43.0": if (UtilIan.equalsApprox(x,UtilIan.roundTo(x,0))) { return Long.toString(Math.round(x)); } else { return Double.toString(x); } } /** Return the Java double this Value represents * (for use by other primitives in our language.) * @return the Java double this Value represents. */ double doubleValue() { return this.x; } }