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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:20:31+00:00 2026-05-29T05:20:31+00:00

So, this is the logic I am trying to implement: date120 = date5; date90

  • 0

So, this is the logic I am trying to implement:

date120 = date5;
date90 = min(date90,date120);
date60 = min(date60, date90, date120);
date30 = min(date30,date60,date90,date120);

where the min function finds the lowest POSITIVE integer.

And here is how I am looping it:

 if(strStatus != "5" && date5 >= 0)
{
    date120 = date5;
    COUT<<"date30 is "<<date30<<" and date60 is "<<date60<<" and date120 is "<<date5<<" and date90 is "<<date90<<ENDL;
    if((date120 < date90) && (date120 >= 0))
    {
        date90 = date120;
        COUT<<"and date90 is "<<date90<<ENDL;
        if((date90 < date60) && (date90 >= 0))
        {
            date60 = date90;
            COUT<<"and date60 is "<<date60<<ENDL;
            if((date60 < date30) && (date60 >= 0))
            {
                date30 = date60;
                COUT<<"and date30 is "<<date30<<ENDL;
            }
        }
        if((date60 < date30) && (date60 >= 0))
            date30 = date60;
    }
    if((date90 < date60) && (date90 >= 0))
    {
        date60 = date90;
        COUT<<"and date60 is "<<date60<<ENDL;
        if((date60 < date30) && (date60 >= 0))
            date30 = date60;
    }
    if((date60 < date30) && (date60 >= 0))
    {
        date30 = date60;
        COUT<<"and date30 is "<<date30<<ENDL;
    }
    COUT<<"Because there was a 5 and date30 is "<<date30<<" and date60 is "<<date60<<ENDL;
}

And the output in the logs looks like :

date30 is -1 and date60 is -1 and date120 is 15 and date90 is -1
Because there was a 5 and date30 is -1 and date60 is -1

Am I doing something wrong with my logic? Am I missing something logic wise? Is there a simpler way to do this?

  • 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-29T05:20:31+00:00Added an answer on May 29, 2026 at 5:20 am

    Well in regards to @Rob’s anwer, he needs to restrict min to the lowest positive integer, so I suggest you implement a custom min function such as

    int minpos( int x, int y ) {
        return x <= 0 ? y : ( y <= 0 ? x : std::min( x, y ) );
    }
    

    and then use what @Rob suggests:

    date120 = date5;
    date90 = minpos( date90, date120 );
    ...
    

    Don’t forget to #include <algorithm>

    I assume if both numbers are non-positive it doesn’t matter which one is returned.

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

Sidebar

Related Questions

I have this piece of logic I would like to implement as a trigger,
what is the logic behind this on this website last activity: 1 min ago
I am trying to implement a function on jquery datatable, that returns the 1st
I am trying to implement logic captcha in my app. I have scaffolded simple
I'm trying to implement an ActionMailer function that will send out a newsletter to
First, I'll explain the situation and the logic that I'm trying to implement: I
I'm trying to implement basic placeholder logic with jquery for textarea.. But there is
I'm trying to implement a multi threaded, recursive file search logic in Visual C++.
I am trying to build openid login system for my website. To do this
I got this logic in a control to create a correct url for an

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.