473,320 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

sp0
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 2645

"sp0" <an*******@anonymous.com> 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
sp0
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

"sp0" <an*******@anonymous.com> 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
In article <Xn*******************************@199.45.49.11> ,
sp0 <an*******@anonymous.com> 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
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

"sp0" <an*******@anonymous.com> 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
In article <Xn*******************************@199.45.49.11> ,
sp0 <an*******@anonymous.com> 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
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
Buster <no***@nowhere.com> wrote in message news:<c2**********@newsg4.svr.pol.co.uk>...
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?


Why not also leave numbers in binary or hexadecimal form for her?
Can't she convert them to decimal herself?

The needs of the machine and the needs of the human are different.
Have the machine use whatever format is most efficient for its own
work, and have it perhaps convert to another format to show the human.
Why on earth would she care how the computer stores the numbers, as
long as the answers come out right? Do you care what makes the sun
shine, or is it enough to know that it shines and will almost
certainly continue to shine for billions of years?

Regards,
Buster.

Jul 22 '05 #10
ju*******@hotmail.com wrote:
Buster <no***@nowhere.com> wrote in message news:<c2**********@newsg4.svr.pol.co.uk>...
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?


Why not also leave numbers in binary or hexadecimal form for her?
Can't she convert them to decimal herself?


It goes without saying that the numbers will be returned in binary form
in the scheme I have described. Are you suggesting that the value of
"a+b" (where a and b are rationals) should be a string? By all means
provide utility functions to create string representations in whatever
format you like, but they won't be used until after the users have
finished their calculations, and those calculations will in general be
simpler to program if you use the simpler numerator-denominator
representation.
The needs of the machine and the needs of the human are different.
Not in any essential way, when it comes to calculating with integers.
Have the machine use whatever format is most efficient for its own
work, and have it perhaps convert to another format to show the human.
What's your point? What's wrong with the numerator-denominator format?
That's how I prefer to write fractions when calculating on paper, the
reasons being essentially the same as the reasons that I would use that
format internally in a rational number class.
Why on earth would she care how the computer stores the numbers, as
long as the answers come out right?
The concept of a rational number is defined in terms of a numerator and
denominator. It really is, honest. A rational number is an equivalence
class of ordered pairs (a, b) where a and b are integers, b is nonzero
and (a, b) is defined to be equivalent to (c, d) if and only a*d == b*c.
Anyone who provides me with a rational number class had better assume
I'm going to be interested in obtaining a numerator and denominator from
an instance.

Given two rational number classes I would try, /ceteris paribus/, to
choose the more efficient. If this were independent of the internal
representation then fine, but it isn't.
Do you care what makes the sun
shine, or is it enough to know that it shines and will almost
certainly continue to shine for billions of years?


Sure I care what makes the sun shine. Where's your childlike wonder? If
everyone thought like that we'd all still be in dark ages.
Regards,
Buster.

Jul 22 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: StenKoll | last post by:
Help needed in order to create a register of stocks in a company. In accordance with local laws I need to give each individual share a number. I have accomplished this by establishing three tables...
16
by: jose_luis_fdez_diaz_news | last post by:
Hi, If I don't include <libgen.h> I get then warnig below in regcmp call: warning: improper pointer/integer combination: op "=" but if I include it the warning is not shown, but them program...
5
by: Jeff | last post by:
I am trying to crete a method that will convert an improper fraction to a mixed number... I am not sure how about how to acomplish this. I know I can get the remainder with the modulus operator...
4
by: david.w.anderson1 | last post by:
This is a homework assignment. The code works but does not "catch" all the improper input. The requirement is to be able to accept one input currency, which is error checked as a valid entry, and...
3
by: Manuel | last post by:
Hello. I have a class where the object are created with the data retrieved from a db. The data retrieved is an image and when this data doesn't exist the constructor must generate it. well, i...
14
by: thehobbit | last post by:
Hi, Could anyone give ideas on how to add 4 20 digit numbers in ANSI C and pass the result back to a calling program in COBOL? We were able to add up to 15 digit numbers without any problems,...
48
by: istillshine | last post by:
When I used gprof to see which function consumed most running time, I identified the following one. sz was less than 5000 on average, but foo had been called about 1,000,000 times. I have tried...
3
by: tbeers | last post by:
Good morning. I am using Access 2007 with all users running runtime. I created a login table that functions very well by adding logins and deleting logins as people log in and out of the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.