Patent ID: 7969149

Claim:
A magnetic sensor comprising a measuring section, a storage section and an operating section, wherein the measuring section has a magnetoresistive element in which a pinned layer having a magnetization pinned in a certain direction and a free layer changing its magnetization direction depending on an external magnetic field are stacked with a non-magnetic intermediate layer in between, and a magnetic field applying means for applying, to the magnetoresistive element, a bias magnetic field in a direction forming a certain relative angle against the magnetization direction of the pinned layer, the measuring section detecting resistance values of the magnetoresistive element in accordance with a change of attitude direction of the magnetic sensor and presence or absence of the bias magnetic field, the storage section stores fixed data which is invariable irrespective of the attitude direction of the magnetic sensor, the fixed data configuring a part of the resistance values measured by the measuring section, and the operating section calculates a predetermined direction component of a magnetic field to be detected by using both of variable data which varies in accordance with the attitude direction of the magnetic sensor, and the fixed data stored in the storage section, the variable data configuring another part of the resistance values measured by the measuring section.