// In an operation between two Dimensions, // we default to the first Number's unit, // so `1px + 2em` will yield `3px`. // In the future, we could implement some unit // conversions such that `100cm + 10mm` would yield // `101cm`. public Node Operate(Operation op, Node other) { Guard.ExpectNode<Number>(other, "right hand side of " + op.Operator, op.Index); var dim = (Number) other; var unit = Unit; var otherUnit = dim.Unit; if (unit == otherUnit && op.Operator == "/") unit = ""; else if (string.IsNullOrEmpty(unit)) unit = otherUnit; else if (!string.IsNullOrEmpty(otherUnit)) { // convert units } return new Number(Operation.Operate(op.Operator, Value, dim.Value), unit); }