Is there any way to convert decimals to fractions in C++? Some sort of function? For example, how can I get the computer to know that 2.5 = 5/2 ?

I'm trying to write a program that will convert slope-intercept form (y=mx+b) to the general form (Ax+By=C). Going from the General Form to Slope-Intercept is a piece of cake (m = -A/B, b = C/B) but without knowing how to convert decimals to fractions, I can't figure out how to go from Slope-Intercept to General.

Thanks in advance!