449,059 Members | 1,278 Online Need help? Post your question and get tips & solutions from a community of 449,059 IT Pros & Developers. It's quick & easy.

# is there a reason why to make mix numbers improper when adding?

 P: n/a Is there a reason why to make mix numbers improper when adding? It seems when subtracting and adding, adding a subtracting the whole numbers and fraction parts should be sufficient? what'ch think Jul 22 '05 #1
10 Replies

 P: n/a "sp0" wrote in message news:Xn*******************************@199.45.49.1 1... Is there a reason why to make mix numbers improper when adding? It seems when subtracting and adding, adding a subtracting the whole numbers and fraction parts should be sufficient? what'ch think Please give a specific code example of what you mean. I don't understand your questions. -Mike Jul 22 '05 #2

 P: n/a Please give a specific code example of what you mean. I don't understand your questions. temp.whole = whole - obj2.whole; temp.numer = ((whole * denom + numer)*obj2.denom) - ((obj2.whole * obj2.denom + obj2.numer)*denom); temp.denom = denom * obj2.denom; temp.reduce(); subtracting the wholes instead of making both fractions improper Jul 22 '05 #3

 P: n/a "sp0" wrote in message news:Xn*******************************@199.45.49.1 1... Please give a specific code example of what you mean. I don't understand your questions. temp.whole = whole - obj2.whole; temp.numer = ((whole * denom + numer)*obj2.denom) - ((obj2.whole * obj2.denom + obj2.numer)*denom); temp.denom = denom * obj2.denom; temp.reduce(); subtracting the wholes instead of making both fractions improper So what other method would you propose? Does it produce correct results? -Mike Jul 22 '05 #4

 P: n/a In article , sp0 wrote: Is there a reason why to make mix numbers improper when adding? It seems when subtracting and adding, adding a subtracting the whole numbers and fraction parts should be sufficient? what'ch think It need not be done that way, but when multiplying or dividing mixed numbers it is much easier to do in improper fraction form. Jul 22 '05 #5

 P: n/a On Mon, 1 Mar 2004, sp0 wrote: Is there a reason why to make mix numbers improper when adding? It seems when subtracting and adding, adding a subtracting the whole numbers and fraction parts should be sufficient? what'ch think 75/7 * 77/5 Jul 22 '05 #6

 P: n/a "sp0" wrote in message news:Xn*******************************@199.45.49.1 1... Please give a specific code example of what you mean. I don't understand your questions. temp.whole = whole - obj2.whole; temp.numer = ((whole * denom + numer)*obj2.denom) - ((obj2.whole * obj2.denom + obj2.numer)*denom); temp.denom = denom * obj2.denom; temp.reduce(); subtracting the wholes instead of making both fractions improper You will get help on this group, if you post compilable code, say what you expect the code to produce, and what it produces instead. At the moment no-one has very much idea what your problem is. This is covered in the FAQ, 'How to I post a question about code that doesn't work correctly?' http://www.parashift.com/c++-faq-lit...t.html#faq-5.8 john Jul 22 '05 #7

 P: n/a In article , sp0 wrote: .... It seems when subtracting and adding, adding a subtracting the whole numbers and fraction parts should be sufficient? what'ch think That's how I was taught to do it in primary school long ago. Ken Pledger. Jul 22 '05 #8

 P: n/a sp0 wrote: Is there a reason why to make mix numbers improper when adding? Is there a reason to store a fraction as a whole number and a fractional part? Doesn't it lead to a lot of unnecessary complications (like this one) in your code? It seems when subtracting and adding, adding a subtracting the whole numbers and fraction parts should be sufficient? what'ch think Adding or subtracting the fractional parts will be formally exactly the same as adding or subtracting two improper fractions. All a mixed representation does is add complexity. I suggest you store rationals as numerator-denominator and produce mixed-fraction representations only as required. Or let the user produce them herself. She has access to the (coprime) numerator and denominator and can calculate the quotient and remainder from them, right? Regards, Buster. Jul 22 '05 #9 