Source: http://users.cecs.anu.edu.au/~xzhang/pubDoc/IT/cppmath_ug2b.pdf