We introduce a new topology, weaker than the gap topology, on the space of self-adjoint operators affiliated to a semifinite von Neumann algebra. We define the real-valued spectral flow for a continuous path of self-adjoint Breuer–Fredholm operators in terms of a generalization of the winding number. We compare our definition with Phillips's analytical definition and derive integral formulae for the spectral flow for certain paths of unbounded operators with common domain, generalizing those of Carey and Phillips. Furthermore, we prove the homotopy invariance of the real-valued index. As an example we consider invariant symmetric elliptic differential operators on Galois coverings.