Keep the subtraction order consistent
For A (x₁, y₁) and B (x₂, y₂), use m = (y₂ − y₁)/(x₂ − x₁). Positive slope rises as you move right; negative slope falls. You can work from B to A instead, provided you reverse both subtractions. Reversing only one gives the wrong sign.