Convert fraction to float in c #

Can anyone please help. I am following the tutorial found here as I have a situation where I need to get the equation of a line in the form of the slope of a point i.e. y−y1=m(x−x1)

...

I get to step 3 of the tutorial with no problem, but then I get stuck. To go from this equation y−3=**3/11**(x−4)

to this 11y−33=3(x−4)

(getting rid of the fraction on the right), I have to multiply by 11 on both sides.

However, my problem is that I obviously won't use fractions, but floating point decimal numbers in C #. So my values ​​will be 0.272727

, not 3/11. So I would need to multiply on both sides to give me the correct answer? Or can it be done?

My question is how can I get from this y−3=**0.272727**(x−4)

to 11y−33=3(x−4)

in decimal form?

Does anyone have any suggestions or alternatives that I can use?

Thank you in advance

+3


source to share


3 answers


First, before trying to run the expression that calculates your equation, you must determine what the substring denominator is , or alternatively, after that, multiply your equation and then try to calculate it. Or another way is to use the FRACTION Class



0


source


Faction class



You can actually use fractions in C # By using this you avoid rounding deviation.

+1


source


I think you are wrong in solving the equation for the calculation. You must first solve your equation in one form or another that you can actually calculate. Normal programming languages ​​(not true for Mathematic, etc.) cannot deal with symbolic computation or unknowns. They can only evaluate the result of the expression given by the values ​​for all used variables

+1


source







All Articles