473,781 Members | 2,718 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 5772
In article <34************ *************** *******@microso ft.com>,
"Jeff" <Je**@discussio ns.microsoft.co m> 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.n et
"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************ *************** *******@microso ft.com>,
"Jeff" <Je**@discussio ns.microsoft.co m> 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
2578
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 but I'm not sure what to do to include the decimal part. //----------------------------------------------------------- const char ccBaseChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char sResult = {0}; int iBase;
10
2691
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
11528
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 will only need to handle numbers that increment by1/32. That is 1/32, 2/32, 3/32.... 31/32, 1. If the doublenumber is 0.28 which is between 1/4 and 9/32, the string shouldbe 9/32(go with the bigger number). TIA --------------------------------...
9
2505
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. The reason for this is a UI restriction, where users can only enter a percentage. But in the case where a third needs to be expressed, a
52
1565
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places? ----------------------------------------------------------------------- When formatting money for example, to format 6.57634 to 6.58, 6.5 to 6.50, and 6 to 6.00? Rounding of x.xx5 is uncertain, as such numbers are not represented exactly.
4
1875
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 basic frational arithmatic. using only 3 textboxes. Allowing the user to enter any type of fraction and get a proper reduced fraction answer. Feel Free to use it if you like it. Had to do 2 posts sorry was too long I guess. Parameters: VB.Net code...
135
4323
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
2639
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 splitting. I have a few issues with this theory. Hard codeing char M works fine for my test double -0.5 But I would like it to be more versitile. The format "%2.2f" works fine with my test data, but that should also be versitile. inline void...
0
9639
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10308
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10076
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9939
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7486
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6729
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5375
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4040
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 we have to send another system
3
2870
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.