another incremental port of qi::calc7