The hysteresis of magnetoresistive sensors remains a considerable cause of inaccuracy of positioning applications. The phenomena itself has been well studied and described by different physical and phenomenological models. Various biasing techniques have been proposed. However, the increased fabrication and computational price they require is undesirable. In this paper, a computational algorithm for the compensation of hysteresis of linear and rotary encoders is proposed. A lagging-domain model based on play operators is presented for prediction of hysteresis. The outlined procedure for the calibration of parameters allows the use of the algorithm for various types of encoders without knowing their exact material properties. The method was tested on different anisotropic magnetoresistive and tunneling magnetoresistive sensors. Results show that the impact of hysteresis was reduced by up to 90% without a significant increase of computational time or production costs.