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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:27:58+00:00 2026-06-02T19:27:58+00:00

My andgate works when I use just 1 bit strings, but anything else, it

  • 0

My andgate works when I use just 1 bit strings, but anything else, it doesn’t work at all and tells me “Specific argument was out of the range of valid values. Parameter name: startIndex.”

Anyone know what I’m doing wrong here? And is there a better way to add to the end of a string? Thanks!

private string parsestrings(string s1, string s2)
{
    int n = s1.Length;
    int m = s2.Length;
    int l;
    string s = "";
    if (n > m)
    {
        for(int i = 0; i <= n; i++)
        {
            l = AndGate(s1[i], s2[i]);
            s.Insert(i, IntToBinary(l));
        }
    }
    else
    {
        for (int i = 0; i <= n; i++)
        {
            l = AndGate(s1[i], s2[i]);
            s.Insert(i, IntToBinary(l));
        }
    }
    return s;
}

private int AndGate(int m, int n)
{
    if (m == 1 && n == 1)
        return 1;
    if (m == 1 && n == 0)
        return 0;
    if (m == 0 && n == 1)
        return 0;
    else
        return 0;
}
  • 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-02T19:27:58+00:00Added an answer on June 2, 2026 at 7:27 pm

    Your logic seems a little off. If n > m, then the loop should probably stop at m instead of n:

    for(int i = 0; i <= m; i++)
    {
        l = AndGate(s1[i], s2[i]);
        s.Insert(i, IntToBinary(l));
    }
    

    The second loop seems right, though.

    A second thought is that the condition i <= m should probably be i < m, since s1[m] is one character past the string.

    Finally, you can either follow spender’s advice, or use a StringBuilder instead. It’s generally better for constructing a string than continually adding to and updating a string.

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

Sidebar

Related Questions

i use a table view with custom values and image. Every rows do this
For my application I have to use a undefined number of different detection strategies.
SSE and/or 3D now! have vector instructions, but what do they optimize in practice
I know I'm missing something obvious here but I can't seem to get my
I am using an array in a simple logic simulator program and I want
Hi I asked a question today about How to insert different types of objects
I have an interesting algorithm problem here. The problem is in a way related
i have started to integrate core data in my current project and it is
I have an issue for this line ball* balle = [[ball alloc] initWithPNGFileName:ballPath andGame:game
this is my cellForRowAtIndexPath . - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell

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.