A touch probe is attached to a main shaft, and the position (Pp1) of a tip with the probe in an on state and the position (Pp2) of the tip with the probe in an off state, when the end of the main shaft is positioned at a prescribed position (Ps1), are optically measured. The dead zone length of the probe is calculated based on the positions (Pp1, Pp2), and the apparent length of the probe is calculated based on the positions (Ps1, Pp2). After the substantive length of the probe has been calculated by adding the dead zone length to the apparent length, the probe derives the actual length of a workpiece, and a tool is then attached to the main shaft, the position (Pt1) of the tip of the tool is optically measured and the actual length of the tool is calculated.