Intersection between two line segments

Problem:
Input: Two line segments S1 and S2 in form of their two end points.
Output: Wheter S1 and S2 intersect or not

Algorithm:
Let L1 and L2 be the lines containing the two line segments S1 and S2.

Test for the line segment and line intersection between S1 and L2. If it yields "line does not intersect the line segment" then the two segments S1 and S2 also do not intersect each other.  Otherwise test for the line segment and line intersection between S2 and L1. If this yields "line does not intersect the line segment" then the two segments do not intersect each other, otherwise they do.