From your other thread about scores, if floating point is too much of a performance hit, try fixed point.
Depending on your screen's spatial resolution, you arent likely to encounter extreme gradients (except in the straight vertical/hortizontal cases, which should be handled separately)*
In other words, suppose your screen size was 640x480. The steepest non-vertical gradient you will be able to represent on screen anyway is 480 (ie dy/dx = 480) and the shallowest is 1/640.
You can use a signed 15:16 fixed point format (basically 32-bit signed integer where the lowest 16-bits are assumed to be fractional) which is more than precise enough for any screen based calculation you need to do at that resolution.
*a word of warning. If your line is vertical, the basic gradient is going to be infinite, since dx=0. If you use your basic 2D equation of a line approach as presented, you need to handle pure vertical lines as a special case.