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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:26:07+00:00 2026-06-13T04:26:07+00:00

I was given the following prompt: create a function: BoolAdd(A,B) that performs binary addition

  • 0

I was given the following prompt:

create a function: BoolAdd(A,B) that performs binary addition on lists
A and B (A and B have the same length N) of Boolean values and returns
a list of two elements. The first element is an overflow, which means
that it is returned with the value FALSE unless the addition does not
fit into the same length list as A and B originally. The second
element of the output list is a list of Boolean values that
corresponds to the vector sum of A and B. Make sure that BOOL_ADD is
defined so it works regardless of the value chosen for N.

I’m unsure on how to perform the binary addition, then convert it to boolean. I’m also not sure when overflow would ever be changed to TRUE. Earlier in the question we wrote the following HalfAdder function:

def HalfAdder(A,B):
    S = int((A and not B) or (not A and B))
    C = int(A and B)
    return (S, C)

and the FullAdder function:

def FullAdder(A,B,C):
    AB = int((A and not B) or (not A and B))
    S = int((C and not AB) or (not C and AB))
    CAB = int(C and AB)
    C1 = int((A and B) or (CAB))
    return (S,C1)

Would either of those be incorporated?

Here’s what I have so far, but it’s not working out:

def BoolAdd(A,B):
    L = []
    overflow = False
    for i in range (0,len(A)):
            x = bin(A[i]+B[i])
            x = bool(x)
            L.append(x)
    if (len(L) > len(A)):
        overflow = True

    return [overflow, L]

Any ideas on what I’m doing wrong, or how to approach this problem?

  • 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-13T04:26:08+00:00Added an answer on June 13, 2026 at 4:26 am

    You have a half adder, you need to construct a full adder from those and then chain multiple calls to that together for each element in the input lists, plus the carry from the previous items.

    The chaining is done by using a ripple-carry technique, taking the “carry” output from the previous set of items and feeding it in as the third input.

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

Sidebar

Related Questions

Given the following code: $(.force-selection).blur(function() { var value = $('matched-item').val(); //check if the input's
Given the following code: function Person(firstName, lastName) { this.FirstName = firstName; this.LastName = lastName;
Given a postscript file that has the following header %!PS-Adobe-3.0 I would like to
I created a UIAlertView that is in ViewDidLoad, as the following: prompt = [[UIAlertView
// given following array: $data = array( 0=>array( data=>object1, col=>array( 0=>array( data=>object2, col=>array( 0=>array(
Given following array: var arr = [undefined, undefined, 2, 5, undefined, undefined]; I'd like
Given following Statment: String query = "Select * from T_spareParts where SparePartPK IN (?
Installing egit on indigo im given following options : I've just checked 'Eclipse Egit'
Given the following code: final class retVal { int photo_id; } Gson gson =
Given the following XML: <Contact> <ContactID>41111-f15a-4fa1-b643-47877608f557</ContactID> <ContactStatus>ACTIVE</ContactStatus> <Name>ABC Ltd</Name> <EmailAddress>xxx@xxx.co</EmailAddress> <SkypeUserName>xxxdemo</SkypeUserName> <Addresses> <Address> <AddressType>STREET</AddressType>

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.