Instead of having to know the exact length of each tool and tediously calculating Z axis positions based on the tool's length, the programmer simply instates tool length compensation on each tool's first Z axis approach movement to the workpiece.
What is tool length compensation?
In an CNC Programming Tool length compensation Code is used to adjust for differences in length between different tools, without worrying about those differences in your part program. ... The control compares the Z axis position with this tool touching the surface to the previously stored Z Reference position.
How does G41 and G42 work?
G41 will compensate to the left-hand side of the programmed path from the radius of the tool while, G42 will have the tool move along the right-hand side of the programmed path to compensate for the radius of the tool.