handle negative values in RHS and ratios properly

We needed the smallest non-negative ratio.