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 7604521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:55:53+00:00 2026-05-30T23:55:53+00:00

Say I have two (positive) arbitrary decimal numbers, a and b. I want to

  • 0

Say I have two (positive) arbitrary decimal numbers, a and b.

I want to be able to count the number of integers that exist between a and b (a less than or equal to [Valid Integers] which is less than b) such that none of them exceed arbitrary number L. Is there an easy way to do this? I’ve tried loops and floors/ceilings but none of it is working the way I want it to and it’s just getting to be messy.

  • 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-05-30T23:55:54+00:00Added an answer on May 30, 2026 at 11:55 pm

    The simple case is:

    Count = Math.Min(Math.Max(a, b), L) - Math.Min(a,b);
    

    However that has issues when L is less than both a and b, and doesn’t cater for decimal numbers.

    As such, give this a go:

    int Count(double firstInput, double secondInput, double limit = int.MaxValue)
    {
        int minInput = (int)Math.Ceiling(Math.Min(firstInput, secondInput));
        int maxInput = (int)Math.Floor(Math.Max(firstInput, secondInput));
    
        int L = (int)Math.Floor(limit);
    
        if (L<minInput)
            return 0;
    
        bool maxInputHasDecimals = (maxInput != Math.Max(firstInput, secondInput));
        return Math.Min(maxInput, L) - minInput + (maxInputHasDecimals ? 1 : 0);
    }
    
    Count(56.67, 67.8); // 11
    Count(56.67, 67.8, 62.0); // 6
    Count(56.67, 67.8, -3); // 0
    Count(-10, -5, -3); // 5
    Count(-10, -5, -7); // 3
    Count(56.67, 67.0); // 10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have two Java apps that I wrote: Ping.jar and Pong.jar and they
Say I have two classes and have a requirement that the primary key property
Say I have two functions that expect ...rest parameters private function a(...myParams):void { trace(myParams.length);
Say we have two pointers to objects that can contain a property equal and
say I have two files: file1 and file2 is there a single command that
Say you have two hashes H(A) and H(B) and you want to combine them.
Say I have two tables I want to join. Categories: id name ---------- 1
Say I have two buttons in my model's index view that are used to
Say we have two sequences and we and we want to combine them using
Say you have two binary values 001011 001111 How can you get the number

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.