Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7832641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:19:49+00:00 2026-06-02T12:19:49+00:00

As part of a calculator app, I am trying to implement uses with sigma

  • 0

As part of a calculator app, I am trying to implement uses with sigma notation. However, the result it prints out is always a decimal, and the rest isn’t important. I simply want to change the decimal to a fraction.

I already have the reduce function, the problem I’m having is getting from a decimal like this: ‘0.96875’ to it’s fractional value, ’31/32′

Thanks!

PS: I’ve looked into just about everything, and for the life of me, I can’t figure this out. All I need at this point is how to take the decimal out of it, and I can then reduce it.

Here is my reduce method:

    -(void)reduce {

    int u = numerator;
    int v = denominator;
    int temp;

    while (v != 0) {
        temp = u % v;
        u = v;
        v = temp;
    }

    numerator /= u;
    denominator /= u;

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T12:19:51+00:00Added an answer on June 2, 2026 at 12:19 pm

    Found this out myself. What I did was multiply the numerator and denominator by 1000000 (recalling that the decimal looked like .96875/1) so that it looked like 96875/100000.

    Then, I used this reduce method to bring it into lowest terms:

        -(void)reduce {
    
        int u = numerator;
        int v = denominator;
        int temp;
    
        while (v != 0) {
            temp = u % v;
            u = v;
            v = temp;
        }
    
        numerator /= u;
        denominator /= u;
    
    }
    

    And finally,I used a print method to get it into fraction form:

    //In the .h
    @property int numerator, denominator, mixed;
    -(void)print;
    
    //In the .m       
    @synthesize numerator, denominator, mixed;
    
    -(void)print {
        if (numerator > denominator) {
            //Turn fraction into mixed number
            mixed = numerator/denominator;
            numerator -= (mixed * denominator);
            NSLog(@"= %i %i/%i", mixed, numerator, denominator);
        } else if (denominator != 1) {
            //Print fraction normally
            NSLog(@"= %i/%i", numerator, denominator);
        } else {
            //Print as integer if it has a denominator of 1
            NSLog(@"= %i", numerator);
        }
    }
    

    And got my desired output:

    31/32
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well I am developing a simple Tip Calculator app as a part of a
Part of my app caches web pages for offline viewing. To do that, I
Part of an app I am working on includes a log file viewer, with
I'm to implement a fullscreen layout for a Web app according to custom specs.
I have a function which is used as part of a calculator. I had
I'm writing an app to help facilitate some research, and part of this involves
In creating a ruby on rails / jquery app, there's a part of a
I'm trying to upload some data to my App Engine datastore using the bulkuploader.
I'm a C# newbie. I want to write a calculator app in C#. Would
I am working on getting a simple calculator working as part of my adventure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.