Firstly emf is measured. to measure emf,we take the difference between the two half cell potentials. we cannot find the value of electrode potential for single electrode as it constitute only half cell, which cannot loose or gain electrons by itself.so its measured by using some other electrode as reference. and we commonly take Standard Hydrogen Electrode(S.H.E) as refrence,having electrode potential as zero,which makes calculations easy. then,the direction of flow of current is noticed,which tells whether oxidation takes place or reduction.accordingly,electrode potential is termed-oxidation or reduction potential. Mg electrode when combines with S.H.E,pushes electrons into external circuit and forms the anode, i.e. oxidised to Mg+2 ions. Mg -> Mg+2 + 2e- and we take,anode on left side in cell representation. so cell formed will be shown as Mg|Mg+2 || H+|H2 so, E0(cell) = E0(right) - E0(left) = E0(cathode) - E0(anode) = 0 - E0(Mg+2|Mg) E0(cell) = - E0(Mg+2|Mg) hence, it is said to have a negative value. TRIED TO CLEAR EACH STEP.HOPE YOU UNDESTAND IT.GOOD LUCK!
Connect to she,as we can find the difference,she has 0 potential