I thought this would be simple, but searching Google didn\'t seem to help.
I\'m basically trying to write a function which will return a ratio as a string (eg 4:3) w
Other commentators have given good solutions for integers; if you really have to deal with floating-point values, though, you'll need something else. In general, two real numbers won't have a clean ratio that can be prettily printed; what you want is the closest rational approximation. Probably the best way to go about finding that is just to compute the continued fraction expansion of the quotient; Mark Dominus gives a good introduction to those on his blog.