It really depends on how your the language compiles your code to machine instructions.
The naive view, in which we assume each operation(- and /) is compiled to a machine instruction, would suggest that first function is better because it involves only 3 operations (two subtractions and one division vs three subtractions and two divisions).
Moreover it seems reasonable to assume that division is a more costly operation than subtraction, especially with floats.
One can always pick clever values for a and b such that the slope is always a division of whole numbers.
in response to comment:
Picking clever values is easy, assuming calculating the lcm is easy/precise.
int[] get_slope(float Xa, float Xb, float Ya, float Yb) {
dX = (Xa - Xb)
dY = (Ya - Yb)
lcm = (dX,dY)
int[] slope = [2]
slope[0] = int(dX*lcm)
slope[1] = int(dY*lcm)
return slope
}
slope[0] and slope[1] are both guarantied to be whole numbers, so no precision is lost. The slope array can be treated as a rational number.
Maybe not the answer you're looking for, but an interesting question none the less.