Current methods for generating curves in numerically controlled systems rely on a Boolean formulation of the step selection problem. This paper takes a different approach, in which the next step is selected by solving an integer programming problem. The structure of this problem is such that a step maximizing the advance along the curve can be obtained by inspection. This criterion reduces the number of steps required to traverse the curve and results in a high degree of smoothness and accuracy. Based on this formulation, step selection rules are derived for both implicitly and parametrically defined curves. Parametric curve representation arises most naturally in the design of cams. The proposed method can be used to generate a cam profile with an accuracy equal to the resolution of the machine tool. Examples and appropriate formulas are given for drum cams and for plate cams with a roller, flat-faced or oscillating follower.