numeric algorithm from ACM 358