Representing 2D line as two variables, all cases 
Is it possible to represent a line in the general case using only two variables (namely floats or doubles)? By this I mean being able to convert a line into those two variables and successfully converting them back without loss of data or the algorithm failing for specific cases.

I know it can be done with three, since any line can be represented as the coefficients in Ax + By = C, but I can't represent a line using two using the coefficients in Ax + By = 1, since this representation produces infinite values for A or B if the line passes through the origin, and I can't use the coefficients m and b in y = mx+b since m becomes infinite for vertical lines.

The general approach in computational geometry has been skepticism toward "minimal representation", and rather be looking for numerical representations that present the fewest exceptions needing to be handled (for more streamlined code).
In addition, from an object-oriented software standpoint, when we utilize vector-based objects in representations, the cognitive load is based on the number of objects in the representation, not the number of scalars buried in the objects.
Based on that thinking, a straightforward representation of a 2D line, stated as a vector predicate is:
p • o == L
Where p = [ x y] is any point on the line, o is the line's orientation (direction vector (unit vector) pointing perpendicular to run direction of line:
o <-- ( dy , -dx) normalized
and L is the location of the line, given as a coordinate along the 2D rotated axis pointing out direction o.
The beauty of this approach is that every line may be represented numerically by two features, orientation o and location L, where both have a clear geometric meaning that can be sketched or visualized. 
