Cartesian product algorithm for products and quotients when inputs straddle zero