ratio = number1 / number2

Code:ratio = number1 / number2![]()

It is, but it shouldn't be! Far too much processing power wasted on modern computers.It is that easy.
private const double P = 0.000000000000001;
public double GetRatio(double a, double b)
{
return GetRatio(a, b, 1, 1);
}
private double GetRatio(double a, double b, double c, double d)
{
if (b * c < a)
while (b * c < a)
c += d;
else if (b * c > a)
while (b * c > a)
c -= d;
return (b * c == a || d < P) ? c : GetRatio(a, b, c, d / 10);
}

Cheers, wouldn't take too much work to hook it upto a progress bar either! Of course you'd have to put the thread to sleep on each recursion or you'd hardly have time to watch it.I like it. Very enterprise-y.....
Yes, I could also run a Web 2.14 (I upgraded) AJAX Enabled website to provide users with a fast access method of getting ratios rather than having to rely on their other systems.Perhaps you caould turn it into a webservice? That would be, like, totally awesome.
Yes, I could also run a Web 2.14 (I upgraded) AJAX Enabled website to provide users with a fast access method of getting ratios rather than having to rely on their other systems.
I'll get the server ordered and look into the best ways of advertising the new service we're offering.
Mick.
Function GetRatio(ByVal a As Integer, ByVal b As Integer) As String
Dim hcf As Integer = 1
For i As Integer = hcf To Math.Min(a, b)
If a Mod i = 0 And b Mod i = 0 Then
hcf = i
End If
Next
Return String.Format("{0}:{1}", a / hcf, b / hcf)
End Function
