Is there a function that can cancel down fractions as far as they go, and then return the denominator and the numerator as separate integers?
This is a discussion on Cancelling down of fractions within the C++ Programming forums, part of the General Programming Boards category; Is there a function that can cancel down fractions as far as they go, and then return the denominator and ...
Is there a function that can cancel down fractions as far as they go, and then return the denominator and the numerator as separate integers?
Something along these lines?
http://www.google.com/search?q=great...on+denominator
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
yer, that kind of thing, but I was wondering if there was a specialised function for it or whether I would have to write my own function for it.
a/b reduces to a/gcd(a,b) / b/gcd(a,b)
Yes, you have to write gcd() for yourself (or find it).
Neither of which is particularly hard.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
Search the post for 'fractions'. That should give you some ideas.