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

  • Home
  • SEARCH
  • 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 8425023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:09:47+00:00 2026-06-10T04:09:47+00:00

I need to know how to do this procedure. calculation1: 1/4 = 0,25 calculation2:

  • 0

I need to know how to do this procedure.

calculation1: 1/4 = 0,25
calculation2: 1/8 = 0,125
calculation3: 47/183 = 0,25683060109289617486338797814207......
calculation4: 58/889 = 0,06524184476940382452193475815523......
calculation5: 1/5 = 0,2

The results of calculations 1, 2 and 5 will give a short result, no periods or and endless string of digits. The results of calculations 3 and 4 are very long and complicated.

How can I check which calculation is an “easy one” and gives a “short” result.

I tried this and it gave a wrong result for sure…
like you can see, the results of the calculations have the datatype double in my application.

static bool IsInt(double x)
    {
        try
        {
            int y = Int32.Parse(x.ToString());
            return true;
        }
        catch
        {
             return false;
        }
    }

I hope it is clear what I’m asking.

  • 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-10T04:09:48+00:00Added an answer on June 10, 2026 at 4:09 am

    If after reducing the fraction as much as possible, the denominator can be expressed as a power of 2 multiplied by a power of 5, then the decimal representation terminates. Otherwise it repeats indefinitely.

    You could test if your division is “good” as follows:

    public bool IsGoodDivision(int a, int b)
    {
        while (b % 2 == 0) { b /= 2; }
        while (b % 5 == 0) { b /= 5; }
        return a % b == 0;
    }
    

    See it working online: ideone

    Note that I am passing the numerator and denominator separately to the method. If you do the division first, then pass the result to your method, you lose precision due to floating point representation error.

    Also for production code you should check that b != 0 because it is not allowed to divide by 0. Without the check the above code would go into an infinite loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to know this so that i could send DTMF and that is going
I know this sounds like a dumb question but I need to ask this.
I know this question is difficult to understand but I need a mathematical equation
I know this is a very broadly scoped question, but what do I need
I know this works very well: def locations(city, *other_cities): print(city, other_cities) Now I need
I need to know when I click on an element if this element has
I have this JQuery code working however I need to know whether how to
Go ahead and let me know if this is not possible: I need to
I don't know if this is a right question, but i need to understand
I have solved this problem, I just need to know what to do. I

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.