See this page. The third algorithm shown is Knuth's. The algorithm is said to be "numerically stable", which implies that it avoids catastrophic cancellation, among other things.
See also here or here. The algorithm given by Knuth goes back to a 1962 paper by Welford. You will find lots of material if you google "welford mean variance".