The present invention relates to a method for contactlessly measuring a relative position of a magnetic field source (102) which produces a magnetic field and a magnetic field sensor (100) in relation to each other. The present invention further also relates to a corresponding displacement sensor. The invention describes an operating principle of a sensor which is based on the Hall effect and which achieves an increase in the sensor output range with a magnet which is simultaneously reduced in size by storing the earlier value when control by the magnetic field is lost. In particular, the method comprises the steps of: calculating the position signal on the basis of a quotient of two magnetic flux density components; calculating a magnitude of the magnetic flux density and comparing the magnitude with a predetermined threshold value; outputting the current calculated position signal if the magnitude of the magnetic flux density is higher than the threshold value; outputting a preceding stored position signal