473,505 Members | 14,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

convert an improper fraction to a mixed number

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 (%), but I am not sure how to get the
quotent.

any insight would be appreciated.

thanks
Nov 17 '05 #1
5 5737
In article <34**********************************@microsoft.co m>,
"Jeff" <Je**@discussions.microsoft.com> wrote:
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 (%), but I am not sure how to get the
quotent.

any insight would be appreciated.


An example would be helpful. I think I know what you want but I am not
sure, as it seems quite simple to me.
Nov 17 '05 #2
int numerator;
int denominator;
....
int wholePart = numerator / denominator;
numerator = numerator % denominator;

you will now have a mixed number: whole part, numerator, and
denominator.

Nov 17 '05 #3
Incidentally, I built and entire Fraction class, with arithmetic
operations, normalization, etc, if it will help.

Nov 17 '05 #4
Thanks for the feedback. I would be very greateful if you would share your
fraction class and any knowledge about dealing with fractions. I am somewhat
of a novice programmer and could use advice.

I read an interesting articles on codeproject.com
(www.codeproject.com/csharp/Fractiion.asp)... however, this class does not
deal with mixed numbers and always reduces fractions to improper fractions,
if available.

thanks,
jeff reed
97***@verizon.net
"Bruce Wood" wrote:
Incidentally, I built and entire Fraction class, with arithmetic
operations, normalization, etc, if it will help.

Nov 17 '05 #5
Example

improper fraction: 8/5

convert to mixed number...

divide the numerator (8) by denominator (5)... this gives a quotent of 1 and
remainder of 3... the remainder is placed over the divisor (5)

so... the answer is 1 3/5

However, using the arithmitic operators does not provide the answer of a
mixed number. Dividing 8/5 produces 1.6. Using the mod operator only provides
the remainder.

I am a novice programmer so that I am probably missing a simple proccess

Thanks

"Matthew Smith" wrote:
In article <34**********************************@microsoft.co m>,
"Jeff" <Je**@discussions.microsoft.com> wrote:
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 (%), but I am not sure how to get the
quotent.

any insight would be appreciated.


An example would be helpful. I think I know what you want but I am not
sure, as it seems quite simple to me.

Nov 17 '05 #6

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

Similar topics

1
2560
by: ferran | last post by:
Hi, does anybody know how to convert in C++ from base 10 to any other base without loosing the decimal part of the actual value? I came up with this algorithm to convert from decimal to any base...
10
2661
by: sp0 | last post by:
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
2
11488
by: paul gao via .NET 247 | last post by:
hi all. In my program I need to convert a double number to stringrepresentation in fraction format and vise versa. For example,convert 0.75 to string "3/4" and convert string "1/2" to 0.5.The class...
9
2491
by: arun.hallan | last post by:
I need to derive fractions from decimals as so: 0.3333 = 1/3 0.6666 = 2/3 The decimal could also be 0.33, or 0.3333333 but the point is that it that the fraction needs to be extracted. ...
52
1565
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
4
1859
by: Semajthewise | last post by:
Hi All For those of you that helped me with the questions on this... Thank you! I believe I have solved all the bugs in the code and wanted to post the final product. This is a set of code to solve...
135
4154
by: robinsiebler | last post by:
I've never had any call to use floating point numbers and now that I want to, I can't! *** Python 2.5.1 (r251:54863, May 1 2007, 17:47:05) on win32. *** 0.29999999999999999 0.29999999999999999
2
2612
by: yogi_bear_79 | last post by:
I have a double of unknown length that I need to split at the decimal. I thought I would convert it either to a string or a char. char seems to be the best since it easily lends itself to...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7303
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.