I have a function getSlope which takes as parameters 4 doubles and returns another double calculated using this given parameters in the following way:
double QSw
While the academic discussion going on is great for learning about the limitations of programming languages, you may find the simplest solution to the problem is an data structure for arbitrary precision arithmetic.
This will have some overhead, but you should be able to find something with fairly guaranteeable accuracy.